Skip to content

LogRecord and SpanByte changes #1186

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

Draft
wants to merge 123 commits into
base: main
Choose a base branch
from
Draft

LogRecord and SpanByte changes #1186

wants to merge 123 commits into from

Conversation

TedHartMS
Copy link
Collaborator

This is an initial draft of a PR to convert Garnet to use a new ObjectAllocator with a revised on-disk format that will use only a single log file, change ISessionFunctions to be (Disk)LogRecord-based and propagate this to operations such as Compaction and Migration, remove TKey and TValue from TsavoriteKV, and many related refactors.

This PR will be long-lived as additional task PRs are merged into storage-v2 before it is ready for merge to main (see "Major Remaining Tasks" below). Currently this branch implements ONLY the in-memory portion; the IO work is not yet implemented.

Highlights:

  • ArgSlice and SpanByte have been merged to a PinnedSpanByte struct with much more limited use. SpanByte remains as a static class providing (ReadOnly)Span<byte> extensions.
  • All keys are now either PinnedSpanByte (mostly at and above the GarnetApi layer) or ReadOnlySpan<byte> at the StorageSession and below, including Tsavorite. There are no longer any byte[] keys. The TKey type argument is gone from Tsavorite and Garnet.
    • Non-SpanByte KeyComparer implementations have been removed.
  • Values are either (ReadOnly)Span<byte> or objects implementing IHeapObject. TValue has been removed from TsavoriteKV.
  • "ref TKey", "ref TValue", and "ref RecordInfo" on ISessionFunctions methods are replaced by one of the LogRecord variants, where they are properties.
  • ETag and Expiration are now properties on LogRecord rather than embedded within Value or IGarnetObject. Internally, they are after the Value and *LogRecord manages shifting as Value shrinks and grows; all "record extra length" management is done by LogRecord and is opaque to ISessionFunctions.
  • GenericAllocator has been replaced by ObjectAllocator; for details, see https://github.com/microsoft/garnet/tree/tedhar/object-allocator/website/docs/dev/tsavorite/logrecord.md. Currently only in-memory operations are implemented.
  • For ObjectAllocator, keys and string values that are past a configurable size can "overflow" to out-of-line byte[], keeping the record size manageable. Tsavorite implements this threshold automatically, and LogRecord manages it internally when returning the Key or ValueSpan.
  • SpanByteScanIterator and GenericScanIterator have been unified into RecordScanIterator
  • Some names have been changed for clarity:
    • "Lockable*" and "Manual*" have become "Transactional*"
    • "Transient" locking has become "Ephemeral"

Major remaining tasks (this will be updated as they are implemented):

  • Complete ObjectAllocator single-LogFile IO.
  • Change object-size tracking from page-level granularity to record-level.
  • Performance evaluation and tuning
  • Fix RENAME and any other remaining areas where the Expiration is not propagated as before, as it is no longer part of Value (including IGarnetObject)
  • Clean up error handling related to the VarLenInputMethods functions (make them consistent with returns from RMWMethods, etc.)
  • Implement JsonObject MemorySize/DiskSize
  • Finish converting and re-enabling all Tsavorite Unit Tests
  • Revise the current Garnet.common to be Garnet.core, then re-create Garnet.common as a common layer between Tsavorite and the Garnet processing layer, containing PinnedSpanByte, epochs, Utility functions (some of which are currently duplicated), and so on.
  • Investigate the performance impact of moving further along the (ReadOnly)Span<byte> path by replacing byte* usage (such as was done for Utility.HashBytes).

- Move CountdownWrapper to its own file
- Rename Lockable* to Transactional*
- Rename Transient* to Ephemeral*
TedHartMS added 30 commits April 9, 2025 15:04
…ail, and CopyToReadCache now being fully internal operations.
… no-longer-needed allocator functions that are now done by DLR
Almost done with Migrate changeover to LogRecord
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.

1 participant