4 ms·
Pretty cool, must be something in the air. This is a useful technique, and having it in a self-contained header-only lib is handy too. I made a similar librar
by kthielen 8y ago
Pretty cool, must be something in the air. This is a useful technique, and having it in a self-contained header-only lib is handy too.
I made a similar library for writing data into memory mapped files, also a self-contained header-only lib:
https://github.com/Morgan-Stanley/hobbes/blob/master/include/hobbes/fregion.H https://github.com/Morgan-Stanley/hobbes/blob/master/include...
This one also serializes a representation of the type structure of recorded data so that it can be safely concurrently mmapped and read either with the same code or with the generic PL/compiler that I've developed in this hobbes project.
Where unpredictable disk latency is a problem, we've got a similar header-only lib for logging into shared memory (then have another process to consume this shared memory ring buffer and dump it to disk for concurrent querying):
https://github.com/Morgan-Stanley/hobbes/blob/master/include/hobbes/storage.H https://github.com/Morgan-Stanley/hobbes/blob/master/include...
This pipeline works well for having lightweight C++ processes feeding large volumes of data to generic query processes that we can run out of band to look at this data in various ways (with a Haskell-like query language).
We did hit a slight problem doing things this way that the straightforward representation of data (as in memory) for some cases just used too much space and too much time wasted in I/O. Basically for complex market data, where data structures aren't trivial and recording ~100GB/day makes it very awkward to keep around a few weeks of data for random querying.
So I also made this header-only lib to write data into these mmapped files with a simple compression method (I like to describe it as generalizing Curry-Howard to probabilities) that gives us much better throughput, much smaller files, faster query times, and still support concurrent constant time random access queries:
https://github.com/Morgan-Stanley/hobbes/blob/master/include/hobbes/cfregion.H https://github.com/Morgan-Stanley/hobbes/blob/master/include...
It gives us compression ratios about the same as EOD gzip, but much faster and importantly works online and with these query use-cases we have with hobbes.
Anyway, maybe I should write up those details somewhere else, I just mean to say that this is a useful technique and you can push it very far and do many things with it in a very straightforward way.