Skip to content

Improve RecordInfo performance; remove obsolete VarbyteLengthUtility#1769

Open
TedHartMS wants to merge 3 commits intodevfrom
tedhar/dev-perf3
Open

Improve RecordInfo performance; remove obsolete VarbyteLengthUtility#1769
TedHartMS wants to merge 3 commits intodevfrom
tedhar/dev-perf3

Conversation

@TedHartMS
Copy link
Copy Markdown
Contributor

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)

TedHartMS and others added 2 commits May 4, 2026 17:30
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>
Copy link
Copy Markdown
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 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 RecordSizeInfo fields into an int word and updated allocators/tests to use Set*Inline() / SetIsRevivifiedRecord().
  • Removed VarbyteLengthUtility.cs and updated references/comments to RecordDataHeader.
  • 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.

Comment thread libs/storage/Tsavorite/cs/src/core/VarLen/RecordSizeInfo.cs
Comment thread libs/storage/Tsavorite/cs/src/core/VarLen/RecordSizeInfo.cs
Comment thread libs/storage/Tsavorite/cs/src/core/VarLen/RecordSizeInfo.cs Outdated
Comment thread libs/storage/Tsavorite/cs/src/core/VarLen/RecordSizeInfo.cs Outdated
Comment thread libs/storage/Tsavorite/cs/src/core/Allocator/ObjectAllocatorImpl.cs
Comment thread libs/storage/Tsavorite/cs/src/core/Allocator/LogRecord.cs
Comment thread test/Garnet.test/RespAofTests.cs Outdated
Comment thread test/Garnet.test/RespAofTests.cs Outdated
Comment thread test/Garnet.test/RespAofTests.cs
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