sidnt / lmdz

0 stars 0 forks source link

event driven architecture on lmdz #29

Open sidnt opened 4 years ago

sidnt commented 4 years ago

possible usecase for opening multiple environment files, from the same app eg in an event driven architecture, given, we want to persist the event history away, we might dedicate a separate eventlog mdb file, in which we persist the events sourced from the domainland, in some order. if persistence of events is not required, we might as well, just put these events in a zioqueue, process them, and discard them.

note: here event, is in the functional paradigm, and contains all the information that is needed to bring about a transactional update to the state.

now, we can round up these sourced-from-the-domainland events, in a zioland queue. but that's not all, because we got to persist these events in nvm⁴. we can enlist one zio fiber, with a handle to the eventlog mdb file, in one environment, to sequentially commit write for each event in the queue, to that mdb environment. fair enough. [⁴] nonvolatile memory

another zio fiber, tasked with processing these events, might just open the same lmdb environment, in a read only mode, and read off the events in order, and process them.

this might involve changes to other mdb managed memory. maybe in same mdb data file, maybe spanning several mdb data files, this depends on the app's design. even though, we spread the risk of deletion, across several files, deletion of any of these, might leave us with incomplete data set.

note: it is not strictly necessary, that processing one event produces one transactional update in an lmdb environment. nothing's stopping us from bundling the changes eventually obtained from processing several of these events, into one lmdb txn.

doubt

so, an app might enlists several environments, with different characteristics, flags and configuration, each suitable to a particular region of the app needs. sounds legit?

remember lmdb nesting transactions one behind the other, via the parent txn argument? #doubt what do we know about how does lmdb's execution of a parent transaction, follow this chain of nested transactions? the performance would still depend on whether lmdb executes these individual nested transactions, one after the other. or is it able to do concurrent updates on all the memory regions to be transactionally updated under the parent transaction? is it truly parallel, or effectively sequential? more importantly, does it even matter deep down at that level?

the smallest mutation is an mdb_put

since lmdb is a btree based thing, #doubt does it actually do the leaf modifications sequentially. from the bottom up?

i don't yet understand the degree of concurrency and parallelism operating on the cpu-memory bus.

because if it is effectively sequential, we might as well,