Skip to content

Update CacheSizeTracker and LogSizeTracker#1567

Open
TedHartMS wants to merge 18 commits intodevfrom
tedhar/size-tracker
Open

Update CacheSizeTracker and LogSizeTracker#1567
TedHartMS wants to merge 18 commits intodevfrom
tedhar/size-tracker

Conversation

@TedHartMS
Copy link
Contributor

Major features:

  • Support fine-grained HeadAddress movement (not at page boundary). E.g. if we have a page with a large number of large objects, we can "evict" by clearing individual records, reclaiming the space without having to evict the entire page.
  • Combine the "inline log space" size limit with the heap size limit into one number, and meet this limit by a combination of page and object eviction.
  • SizeTracker is automatically enabled if "memorySize" is specified; this is a limit. If only pageSize and pageCount are specified, there will be no size tracking. PageSize must be specified. If only memorySize and pageSize are specified, the pageCount is calculated from those. PageCount becomes MaxAllocatedPageCount which cannot be changed (although the actual number of allocated pages may be smaller to satisfy the limit). If all 3 are specified, then pageCount is assumed to be intended to limit MaxAllocatedPageCount to be less than (memorySize / pageSize).
  • The "EmptyPageCount" property is removed, although we still have empty pages. This is replaced by MaxAllocatedPageCount which is set from the initial LogSettings and does not change (although eviction may reduce the actual number of allocated pages, it will not exceed this).

There are a number of temporarily [Explicit] tests that still require work to modify from the previous implementation; that work is in progress.

More Comments in BufferAndLoad
Fix RandomReadCacheTest input failure
… for tests; make some ReadAtAddrss and Reviv tests [Explicit] temporarily. A couple Garnet test fixes for required minimum page count
Fix MultiDBManager not propagating SizeTracker start when adding a DB
Fix SortedSetOps using wrong context
Fix Recovery not propagating LastPageFreed
Remove SizeTracker fields that duplicated LogSizeTracker
Fix Recovery eviction-range calculations
Disable some tests temporarily until they can be converted
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements major changes to CacheSizeTracker and LogSizeTracker to enable fine-grained HeadAddress movement (not constrained to page boundaries), combining inline log space and heap size limits into a unified memory target. The implementation automatically enables size tracking when memorySize is specified, and introduces the ability to specify pageCount independently. The PR also removes the EmptyPageCount property in favor of MaxAllocatedPageCount.

Changes:

  • Renamed configuration properties from MemorySize/HeapMemorySize to LogMemorySize with combined inline+heap tracking
  • Added PageCount configuration option to allow specifying page count independent of memory size
  • Replaced EmptyPageCount with MaxAllocatedPageCount (now HighWaterAllocatedPageCount)
  • Implemented fine-grained eviction that can clear individual records within pages
  • Updated size tracking to use observer pattern and track both inline and heap memory together

Reviewed changes

Copilot reviewed 129 out of 130 changed files in this pull request and generated no comments.

Show a summary per file
File Description
ServerOptions.cs Renamed MemorySize to LogMemorySize, added PageCount, renamed IndexSize to IndexMemorySize
GarnetServerOptions.cs Removed HeapMemorySize/ReadCacheHeapMemorySize, added ReadCachePageCount, updated logging
KVSettings.cs Changed MemorySize to LogMemorySize, added PageCount, removed MinEmptyPageCount
LogSettings.cs Updated to use MemorySize (long) instead of MemorySizeBits, added PageCount
CacheSizeTracker.cs Removed LogSizeCalculator, updated to track combined inline+heap memory
TestUtils.cs Updated test utilities to use new configuration names and pageCount parameter
Various test files Updated memory size parameters and adjusted for new MinTargetPageCount requirements
Allocator implementations Updated FreePage logic to check logSizeTracker instead of EmptyPageCount

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Fix some issues (resulting from going to GC.AllocateArray) with reusing allocator pages.
Replace the last NativeMemory allocations in Allocator with GC.AllocateArray.
Move FreePage() up to just below Alloc/ReturnPage() so they're together
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants