Improve RecordInfo performance; remove obsolete VarbyteLengthUtility#1769
Open
Improve RecordInfo performance; remove obsolete VarbyteLengthUtility#1769
Conversation
Optimize RecordSizeInfo struct layout by packing boolean flags (KeyIsInline, ValueIsInline, IsRevivifiedRecord) and small integer fields (KeyLengthBytes, RecordLengthBytes) into a single int word using bit manipulation. This reduces struct size and enables cheaper composite checks like RecordIsInline via a single bitwise AND. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes Tsavorite record sizing metadata by packing RecordSizeInfo flags/byte-count fields into a single word for smaller struct size and cheaper checks, and removes the long-obsolete VarbyteLengthUtility in favor of RecordDataHeader.
Changes:
- Packed
RecordSizeInfofields into anint wordand updated allocators/tests to useSet*Inline()/SetIsRevivifiedRecord(). - Removed
VarbyteLengthUtility.csand updated references/comments toRecordDataHeader. - Added an AOF recovery test that exercises Upsert behavior with expirations.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| test/Garnet.test/RespAofTests.cs | Adds AOF recovery test for Upsert with expirations/TTL checks. |
| libs/storage/Tsavorite/cs/test/RevivificationTests.cs | Updates tests to use RecordDataHeader constants and new RecordSizeInfo setters. |
| libs/storage/Tsavorite/cs/test/ObjectInlineTests.cs | Fixes assertion parameter order. |
| libs/storage/Tsavorite/cs/test/LogRecordTests.cs | Updates constants and adapts tests to packed RecordSizeInfo layout. |
| libs/storage/Tsavorite/cs/src/core/VarLen/RecordSizeInfo.cs | Introduces packed word bitfield and rewrites related properties. |
| libs/storage/Tsavorite/cs/src/core/Allocator/SpanByteAllocatorImpl.cs | Uses SetKeyIsInline/SetValueIsInline with packed RecordSizeInfo. |
| libs/storage/Tsavorite/cs/src/core/Allocator/ObjectAllocatorImpl.cs | Uses SetKeyIsInline/SetValueIsInline with packed RecordSizeInfo. |
| libs/storage/Tsavorite/cs/src/core/Allocator/ObjectSerialization/RecordDataHeader.cs | Switches revivification flagging to packed RecordSizeInfo. |
| libs/storage/Tsavorite/cs/src/core/Allocator/LogRecord.cs | Adjusts IPU sizing logic due to packed RecordSizeInfo/optionals calculation. |
| libs/storage/Tsavorite/cs/src/core/Allocator/LogField.cs | Updates docs to reference RecordDataHeader. |
| libs/storage/Tsavorite/cs/src/core/Allocator/ObjectSerialization/VarbyteLengthUtility.cs | Deletes obsolete utility implementation. |
| libs/storage/Tsavorite/cs/benchmark/YCSB.benchmark/KeySpanByte.cs | Updates benchmark comment references to RecordDataHeader. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…e AggressiveInlining.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Optimize RecordSizeInfo struct layout by packing boolean flags (KeyIsInline,
ValueIsInline, IsRevivifiedRecord) and small integer fields (KeyLengthBytes,
RecordLengthBytes) into a single int word using bit manipulation. This reduces
struct size and enables cheaper composite checks like RecordIsInline via a
single bitwise AND.
Remove obsolete VarbyteLengthUtility.cs (superseded a while ago by RecordDataHeader)