Currently, we have _export_kv_store for syncing changes from db snapshot from worker processes to main process and _write_kv_store_dump to dump full db content for sidctl dump command.
We could possibly reuse a single implementation here because the functionality is very similar. The _export_kv_store would need some edits though as it is currently hard-codes the functionality for the "sync diffs" case only, not being generic to send also the whole db content.
The buffer code now supports using memfd as backend with BUFFER_BACKEND_MEMFD so when editing the _export_kv_store, we should also start using this kind of buffer for converged solution using existing shared code elements to minimize duplication as well as possible bugs (...so we can concentrate more on making the shared part rock solid which will be reused even more in the future).
There's probably one (optimization) dependency here: #81. If we knew how much memory to allocate exactly in advance, we wouldn't need to expand the memfd backend by steps (calling mremap internally each time). So would be better to have #81 resolved first before resolving this issue...