> Speed is not the reason to want to use mmap (I didn't understand it that
> way at least).
I believe it's the main reason.
> In the context (persistent database for lisp objects), lisp objects have
> to be serialized and deserialized, whereas one could just coerce a blob
> of mmapped memory into a C++ object, by casting it, and then manipulate
> the object in place.
You can as well read blob using fread, cast it into C++ object,
manipulate it and fwrite it back. Only extra things you need is
fread/fwrite pair, and it is pretty much trivial.
Actually I once worked on a project where we needed to implement a
custom database in C++. First version used mmap as we saw it as a
simplest way to do it. But then it turned out that it's unreliable: we
could not allocate large block of continuous address space on some
machines, and using windowing would complicate everything.
It took maybe a couple of days to re-implement it using fread/fwrite, we
only had to change I/O related parts keeping interfaces and
datastructures the same. (But I guess our interface was
check-in/check-out friendly.) If we used fread/fwrite from the start it
would barely cost us anything.
> IMO The big win would be to avoid the binary
> serialization layers,
In C/C++ there is no difference -- you can always grab bytes of
structure object no matter whether you're going to use it with mmap or
file I/O.
In CL you, perhaps, can speed up development a bit by dumping raw data
structures, but then you lose portability; it's very well possible that
your 'database' will be readable only by a certain version of CL
implementation; and most likely all dev. time savings you gain by not
writing a serialization layer will be spent on reading documentation on
raw data formats and mmap-related operations. So it would be in fact
harder to implement, and also worse from compatibility standpoint. The
only potential gain is speed.
Even if you're afraid of serialization for some reason, you can try
using struct (:type vector) -- you can dump those things directly into
byte files. Need different base data types? Use different files. Simple, eh?