You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optimizes memory tracking during cache updates by only storing the old entry size, rather than the entire entry. This reduces memory pressure, especially in scenarios with frequent updates to large cache entries.
**Conclusion**: The ~5% overhead is **inherent to the memory-sizing feature**:
207
+
- Size must be calculated via `CreateEntry()` calling the configured `SizeCalculator`
208
+
- Size delta must be tracked for memory accounting
209
+
- This is the minimum overhead for accurate memory tracking
210
+
211
+
### Previous Run (PR #400 - Review Feedback Round 2)
212
+
213
+
-**Fixed overflow logging**: Moved warning log outside do-while loop using `bool overflowed` flag to avoid log spam in high-contention scenarios
214
+
-**Removed ToArray() allocation**: `RecalculateMemorySize()` now iterates directly over `_memory.Values` instead of creating a copy
215
+
-**Skipped primitive size recalculation**: `SetIfHigherAsync` and `SetIfLowerAsync` for `double`/`long` no longer call `CalculateEntrySize()` since primitives have constant size (8 bytes)
216
+
-**Scaled maxRemovals dynamically**: Changed from `const int maxRemovals = 10` to proportional scaling (10 base × overLimitFactor, capped at 1000) to reduce multiple maintenance cycles when significantly over limit
217
+
-**Documented O(n) eviction trade-off**: Added XML docs to `FindWorstSizeToUsageRatio` explaining the performance trade-off vs. complexity of priority queue/sampling approaches
218
+
-**Added exception constructor docs**: Documented that `MaxEntrySizeExceededCacheException` alternate constructors are for serialization/advanced scenarios
219
+
-**Result**: ~5-7% overhead for sizing modes, all 851 tests pass
220
+
221
+
### Earlier Run (PR #400 - Clean _writes Counter)
164
222
165
223
-**Reverted `_writes` counter to simple approach**: Increment is inside `SetInternalAsync` where it always was. Rejected entries (too large) are correctly NOT counted as writes.
166
224
-**Removed MaxRemovals warning log**: Unnecessary - if we hit the limit, the next maintenance cycle continues evicting.
0 commit comments