The effect of switching to TCMalloc on RocksDB memory use
blog.cloudflare.com
The effect of switching to TCMalloc on RocksDB memory use
1–10 of 49 posts
Re: The effect of switching to TCMalloc on RocksDB memory use
#2Re: The effect of switching to TCMalloc on RocksDB memory use
#3Re: The effect of switching to TCMalloc on RocksDB memory use
#4This is really a thing which happens with the glibc allocator and long-lived applications. Back in the day I had a custom chat server which consistently used more and more memory until after about a month it ran out of memory and crashed. I spent quite a while investigating, even annotating every malloc/free in the program to find the leak, only to conclude that there was simply no leak at all in the program and it w…
Re: The effect of switching to TCMalloc on RocksDB memory use
#5There's something to be said about garbage collection as an actual strategy (!!). I know people think that garbage collection is slow, but... very smart people have put their minds on the memory problem.
A generational garbage collector is designed to tackle fragmentation head-on. Every "generation", the garbage collector recompacts all the data, "squeezing" your fragmentation out of the memory area.
Because some data is "longer lived" than other data, the compacted data is placed into a new generational-pool, where it is left alone for the next collection. IE: All data that survived a collection at time T will be left alone at collect time T+1. Maybe at time T+2 will it be re-checked... and those that survive the check at T+2 will be left alone until T+6.
--------------
This generational strategy minimizes the copying / moving of data around the fragmentation issue. Still though: moving / copying data is the singular catch-all solution to fragmentation.
Re: The effect of switching to TCMalloc on RocksDB memory use
#6Re: The effect of switching to TCMalloc on RocksDB memory use
#7It would be interesting to see how jemalloc performs compared to tcmalloc. The article doesn't explain why they choose tcmalloc among other alternative memory allocators.
HN discussion from 2019: https://news.ycombinator.com/item?id=20249743
Re: The effect of switching to TCMalloc on RocksDB memory use
#8Why don’t things like malloc get fixed? I’ve known about these issues for years. Does the core team not know?
Memory allocation is built to some purpose, and the programmer who uses it should be aware of its problems. There's probably a technical reason why the original glibc malloc does what it does (probably better optimized for low-thread counts)
Re: The effect of switching to TCMalloc on RocksDB memory use
#9This is really a thing which happens with the glibc allocator and long-lived applications. Back in the day I had a custom chat server which consistently used more and more memory until after about a month it ran out of memory and crashed. I spent quite a while investigating, even annotating every malloc/free in the program to find the leak, only to conclude that there was simply no leak at all in the program and it w…
This is very common in long-lived Ruby applications as well, where jemalloc seems to be the accepted solution.
Re: The effect of switching to TCMalloc on RocksDB memory use
#10It clear that some of these decisions still hang around today and that switching to a better allocator really can make a huge difference, especially given everything is multiple threads/cores today. But a lot of programmers never even look at memory usage or investigate alternatives. Even the JVM has a boatload of options on allocators for different usages; yet most Java programmers I know just go with the defaults.
Computers may be ridiculously fast and have enormous memory today and maybe you can live with the default; but it doesn't hurt to look, and might even save you money (pay less to AWS!) by reducing your need to allocate more or bigger servers.