-
Notifications
You must be signed in to change notification settings - Fork 40
Persistent Memory
This page is written for the not too far future. At some point, there will be interest in having ONA use more memory than the machine has RAM, and there will be interest in having its memory persistent across runs. There is one extremely simple and highly efficient solution which does both at the same time, and it should be preferred to whatever currently fashionable database: A good old memory-mapped file. In ONA, concepts are lied out in a contiguous block of memory:
Concept concept_storage[CONCEPTS_MAX];
This can be replaced with a memory mapped pointer, pointing to a memory-mapped region of that size instead. Then at startup, at the end of Memory_INIT, iterate over it once to enter the concepts into the concepts hashtable:
for(int i=0; i<CONCEPTS_MAX && concept_storage[i]->id!=0; i++)
{
HashTable_Set(&HTconcepts, &concept_storage[i]->term, concept_storage[i]);
}
Additionally, also map Narsese_atomNames, either by a separate file or by putting it into a struct together with concept_storage, else the terms would print as empty string.