Conversation
Signed-off-by: Jim Rhyness <jrhyness@ca.ibm.com>
limitador-server/src/main.rs
Outdated
| let size = std::cmp::max(MIN_CACHE_SIZE,(memory | ||
| / (std::mem::size_of::<Counter>() + 16/* size_of::<AtomicExpiringValue>() */) as f64) | ||
| as u64; | ||
| as u64); |
There was a problem hiding this comment.
I'm not sure this is entirely safe - if 1000 counters is > free_mem won't we oom?
There was a problem hiding this comment.
Thanks. Good point, and would oom happen if the server was explicitly started with a --cache size ?
|
Thanks for the PR! For more context - this issue arose as on an overcommitted machine I had |
I hit this as well. In my case, on a Mac, |
- Changed sys.available_memory to sys.free_memory ( TODO: test other OSes ) Signed-off-by: Jim Rhyness <jrhyness@redhat.com>
Description
If the cache size is not specified via --cache and there is no available memory reported, it gets set to 0 and qualified counters cannot be cached. This PR introduces a minimum cache size, as proposed in the linked issue.
Related Issue
#466
Tests
With no available memory reported:
With available memory: