-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unexplained sudden increase in memory usage #12364
Comments
is there a formula for calculating max memory usage? My initial understanding is that if set_cache_index_and_filter_blocks is set to true, then total memory usage by rocksdb can be calculated as follows: block cache size per cf + max_write_buffer_number per cf x write_buffer_size per cf for example, say we have 3 cfs and each is configured with the following then total memory usage will be 3 x 1.5 GB + 3 x 4 x 256 MB = 7.5 GB But it seems this formula is still missing something? |
What allocator are you using? We use jemalloc. If you are using jemalloc, can you set |
I'm using jemalloc, I'll look into |
I may have misunderstood your question, in my LOG file i see:
looks like I can set an allocator for block cache? My application that has rocksdb bundled in it is using jemalloc, but I don't pass a memory allocator when constructing the block cache. Is that an issue? |
Probably not an issue. |
so i tried setting dump_malloc_stats but nothing shows up. Note that i'm doing this from rust so i'm using the c api to do this. rust code:
which translates to calling the following c functions:
And per Lines 1166 to 1173 in d1386de
I expect to see a Is there something else I need to call/set to get this to show up? |
correction, it turns out the rust crate by default doesn't build rocksdb with jemalloc and it gates it behind a feature flag so I actually wasn't using jemalloc for rocksdb part at least which explains why the stats were not printing. I'll enable jemalloc with rocksdb and see how that changes perf/memory utilization and will report back if that on its own resolves the issue. |
so even after enabling the feature flag, I still don't see the stats. Just to make sure, the rust library tries to get rocksdb to use jemalloc by setting:
is |
In past tests I usually see RSS with glibc malloc being 2X or more larger than RSS with jemalloc. RocksDB can be a stress test for allocator fragmentation and jemalloc does better at avoiding it. |
update, the rust bindings are the problem as they were not actually getting rocksdb to use jemalloc. After fixing them locally, I can actually see the malloc stats. So i'll push this to prod and see whether that fixes all my memory problems! |
a feature request that might be helpful is to include in the LOG the allocator being used by rocksdb to make sure that users don't think they are using something that they are not actually using. |
Agreed. We could log the value of Lines 138 to 151 in 2940aca
Feel free to submit a PR if you are interested |
@leeqx the rss memory i got from container_memory_rss{app_name=~"service_name.service"}. and other rocksdb memory usage metrics i got using https://github.com/zaidoon1/rust-rocksdb/blob/3e4a0f632a8c0c2839c7d183725c53895110d907/src/perf.rs#L267 Also update, after actually enabling jemalloc, I can confirm the memory issue is definitely fixed thanks for the help everyone! |
I suddenly started seeing the memory usage increase for no apparent reason and it has not come down yet:
I have various metrics tracking memory usage, other things happening in rocksdb but none explain why the memory usage went up to the level it hit without coming back down:
I've also attached the LOG file (although I got the LOG a day after this issue started so not sure how useful):
LOG.txt
Any idea or suggestions to what can cause this?
The text was updated successfully, but these errors were encountered: