Repository navigation
Cellar v1.1.0
What is new, in short:
- One memory budget for everything. Cellar can now count every byte a program holds - its cache, a WebAssembly memory, compiled code - in one place, and free old cached data first when something new does not fit.
- Two-way calls. A link lets two threads call each other; a thread waiting for its answer still answers the other side meanwhile, so the two never lock each other up.
- Tables. Counters and small records that one thread writes and any thread reads at any time, without asking the writer. Also a list of handles any thread can take and give back.
- The cache from any thread. The thread that owns the cache can be asked from another thread, over a channel or a link.
- Less waiting, less waking. Each side of a link sleeps on one word, and a full ring wakes its writer only when the writer is actually waiting for room. A call that could not be sent in its time limit is not sent late.
- Nothing left stuck. Space nobody needs any more - a write a thread abandoned, an old record its last reader has left - is reclaimed the next time the cache needs room.
If you used 1.0.0: a few calls changed (listed below), and all threads of one program must use the same version, because the shared memory layout changed. Data already saved to disk still opens.
Changed from 1.0.0:
INDEX_FILES,packFileandreadSavedmoved to the new entry@bottlify/cellar/advanced, together with the other low-level helpers.- Write options are now one number made by
reserveFlags({ onlyCopy, disk, idle }): pass it toreader.reserve(name, length, flags)andreader.put(name, bytes, flags)instead of an options object. keeper.reserve(andKeeperCalls.reserve) is(name, length, flags, known, place, writer?): it fills theplacearray you pass and returns true, or returns false, instead of creating an object.createRingMemory(capacity, bell, roomBell)takes a second doorbell, rung when room frees up while the writer waits for it.- Too many queued calls: both a link side and a channel client limit them with
unsentLimit, and refuse the extra call as not sent. - A time limit now also covers waiting to send: a call that could not get room in time fails with
ChannelNotSentorLinkNotSent; a limit of 0 sends only if there is room right now. - A link side closes in one way only, whoever starts it, and only one
servemay run on a side. account.fits(bytes, kind?, given?)can count memory about to be given back.- The shared memory layouts of the cache, rings and tables changed; memory from another version is refused when opened.
Added:
- Memory budget:
createAccountMemory,openAccount,openCharge,memoryBytes,ACCOUNT_UNIT,RUN_HOLDER. - Links:
createLinkMemory,openLink,LinkClosed,LinkNotSent,LinkNotAnswered. - Tables:
createTableMemory,openTable. - The cache from another thread:
openKeeperClient,serveKeeperChannel,answerKeeper,keeperWords,linkCarrier. - Clearer channel errors:
ChannelNotSent(the call never left) andChannelNotAnswered(it left, no answer in time). - Helpers:
reserveFlags,mayWait(may this thread block?),grainsOf. - Documentation for each part, including how long data lives, who may write where, and what time limits cover; and a page on how all this is tested.