mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
chore: change how we track memory_budget during evictions (#3457)
* chore: change how we track memory_budget during evictions We compared memory_budget vs 0 before inserting a new item in DbSlice, and retired cool pages if we are low on memory. The problem - when we decide whether we allow growing a table, we estimate the possible object size increase due to the future table growth. And the memory check described before was not consistent with the actual logic that rejected the insertion. Moreover, the memory_budget tracking interaction with EvictionPolicy was over-complicated: we passed the memory_budget counter to the evp object and then read it back, even though evp did not track object deletions memory impact during objects evictions. Now, we remove the responsibility from evp to update memory_budget_ so it's solely updated by DbSlice. We also update memory_budget_ during deletions, and when we pass it to evp, we add cool memory size as potential memory resource to avoid rejections in case we have lots of cool memory. Fixes #3456 --------- Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
41be819dbb
commit
7c84b8e524
4 changed files with 51 additions and 42 deletions
|
@ -575,7 +575,7 @@ class DbSlice {
|
|||
bool expire_allowed_ = true;
|
||||
|
||||
uint64_t version_ = 1; // Used to version entries in the PrimeTable.
|
||||
ssize_t memory_budget_ = SSIZE_MAX;
|
||||
ssize_t memory_budget_ = SSIZE_MAX / 2;
|
||||
size_t bytes_per_object_ = 0;
|
||||
size_t soft_budget_limit_ = 0;
|
||||
size_t table_memory_ = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue