| ▲ | dale-cooper 5 hours ago | |||||||||||||||||||||||||
Maybe I'm missing something, but two thoughts: 1. Doesn't the overcommit feature lessen the benefits of this? Your initial allocation works but you can still run out of memory at runtime. 2. For a KV store, you'd still be at risk of application level use-after-free bugs since you need to keep track of what of your statically allocated memory is in use or not? | ||||||||||||||||||||||||||
| ▲ | nickmonad 5 hours ago | parent | next [-] | |||||||||||||||||||||||||
Author here! Overcommit is definitely a thing to watch out for. I believe TigerBeetle calls this out in their documentation. I think you'd have to explicitly disable it on Linux. For the second question, yes, we have to keep track of what's in use. The keys and values are allocated via a memory pool that uses a free-list to keep track of what's available. When a request to add a key/value pair comes in, we first check if we have space (i.e. available buffers) in both the key pool and value pool. Once those are marked as "reserved", the free-list kind of forgets about them until the buffer is released back into the pool. Hopefully that helps! | ||||||||||||||||||||||||||
| ▲ | justincormack 5 hours ago | parent | prev [-] | |||||||||||||||||||||||||
You can work around overcommit by writing a byte to every allocated page at allocation time, so that it has to be actually allocated. | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||