Writing a Memory Allocator for Fast Serialization
1–10 of 23 posts
Re: Writing a Memory Allocator for Fast Serialization
#2* libsrt i64-i64 map (equivalent to std::map : > 10M QPS
* libsrt string-string map (equivalent to std::map : > 1M QPS (> 2M QPS if key size [1] Repository: https://github.com/faragon/libsrt
[2] Benchmarks: https://github.com/faragon/libsrt/blob/master/doc/benchmarks...
Re: Writing a Memory Allocator for Fast Serialization
#3Re: Writing a Memory Allocator for Fast Serialization
#4This is a similar approach to what Jonathan Blow demo'd recently in his Jai language. He uses relative offsets from the location of the pointer instead of from the base of the region though. The advantage there is that you don't need to pass around a reference to the current heap, the disadvantage is that copying/moving is harder but that can be mitigated wit compiler support.
Re: Writing a Memory Allocator for Fast Serialization
#5If you just don’t wanna use C++, fine. But this looks like a great fit for it to me. Avoid the STL, turn off the features you don’t need, etc.
Re: Writing a Memory Allocator for Fast Serialization
#6Re: Writing a Memory Allocator for Fast Serialization
#7What happens if the program unexpectedly terminates during an update to these persistent data structures? Is the mmap'ed file corrupted, or still in a usable state?
Re: Writing a Memory Allocator for Fast Serialization
#8I don’t understand the comment about not being able to use C++. In C++, you certainly have the same low-level control over your objects as you do in C. You gain a lot of syntax sugar and additional type safety. If you just don’t wanna use C++, fine. But this looks like a great fit for it to me. Avoid the STL, turn off the features you don’t need, etc.
Re: Writing a Memory Allocator for Fast Serialization
#9What happens if the program unexpectedly terminates during an update to these persistent data structures? Is the mmap'ed file corrupted, or still in a usable state?
This problem is generally hard. See [Ensuring data reaches disk](https://lwn.net/Articles/457667/)
Re: Writing a Memory Allocator for Fast Serialization
#10I don’t understand the comment about not being able to use C++. In C++, you certainly have the same low-level control over your objects as you do in C. You gain a lot of syntax sugar and additional type safety. If you just don’t wanna use C++, fine. But this looks like a great fit for it to me. Avoid the STL, turn off the features you don’t need, etc.
The problem is C++ brings in many extra pointers. For example, the vtable pointer used in virtual functions. All the pointers not converted to offset can be invalid in next process that deserializes the object.