Repository navigation
Remove the LightEpoch EntryAt accessor - #2033
Merged
Tiago Nápoli (tiagonapoli) merged 3 commits intoAug 7, 2026
Merged
Tiago Nápoli (tiagonapoli) merged 3 commits into
Tiago Nápoli (tiagonapoli) merged 3 commits into
Conversation
Tiago Nápoli (tiagonapoli)
force-pushed
the
tiagonapoli-lightepoch-entryat-cleanup
branch
from
August 6, 2026 18:25
82f9166 to
0de0373
Compare
Tiago Nápoli (tiagonapoli)
force-pushed
the
tiagonapoli-lightepoch-entryat-cleanup
branch
from
August 6, 2026 18:30
0de0373 to
a916c07
Compare
Tiago Nápoli (tiagonapoli)
force-pushed
the
tiagonapoli-lightepoch-entryat-cleanup
branch
from
August 6, 2026 18:34
a916c07 to
6a3b6f7
Compare
…e debug asserts Remove EntryAt and inline every epoch table access as `*(tableAligned + i)`, so no helper sits on the epoch hot path. Add DebugAssertEntryReserved / DebugAssertEntryNotReserved for the slot-reservation checks. DebugAssertEpochAcquired now builds on the former, and Acquire's inline `Debug.Assert(entry == kInvalidIndex)` goes through the latter. Fold the ad-hoc `Debug.Assert(entry > 0, "Trying to refresh unacquired epoch")` in ProtectAndDrain into DebugAssertEpochAcquired. Co-authored-by: Copilot App <[email protected]>
Tiago Nápoli (tiagonapoli)
force-pushed
the
tiagonapoli-lightepoch-entryat-cleanup
branch
from
August 6, 2026 18:36
6a3b6f7 to
12e3607
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (2)
libs/storage/Tsavorite/cs/src/core/Epochs/LightEpoch.cs:618
- This re-dereferences
tableAligned + entrymultiple times in a tight path. Consider caching a singlerefto the slot (e.g.,ref var slot = ref *(tableAligned + entry);) and then usingslot.localCurrentEpoch/slot.threadIdto reduce repeated address computation and improve readability without reintroducing a helper call frame.
if ((*(tableAligned + entry)).localCurrentEpoch != 0)
return false;
var epoch = Volatile.Read(ref CurrentEpoch);
if (Interlocked.CompareExchange(ref (*(tableAligned + entry)).localCurrentEpoch, epoch, 0) != 0)
return false;
// The slot is now exclusively ours, so threadId needs no interlocked write.
(*(tableAligned + entry)).threadId = Metadata.threadId;
libs/storage/Tsavorite/cs/src/core/Epochs/LightEpoch.EntryTable.cs:18
- Both assertions reuse the same primary
messagebut provide different detail strings, which can lead to confusing output (and potentially multiple assertion dialogs) whenindexis invalid. Consider collapsing this into a single assertion with a clearer, specific detail for each failure mode (or early-return after the first failure) so debug failures are more actionable.
private static void DebugAssertEntryReserved(int index, string message = "No epoch table entry is reserved for this thread")
{
Debug.Assert(index != kInvalidIndex, message, "No slot is reserved for this thread.");
Debug.Assert(index > kInvalidIndex && index <= kTableSize, message, $"Slot {index} is out of range.");
}
Badrish Chandramouli (badrishc)
approved these changes
Aug 6, 2026
Tiago Nápoli (tiagonapoli)
merged commit Aug 7, 2026
4ba5ebf
into
microsoft:main
210 of 211 checks passed
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
Follow-up cleanup to
LightEpochafter #2015. Cosmetic only.EntryAtand inline every epoch table access as*(tableAligned + i). AnAggressiveInliningaccessor on the epoch hot path adds an inline frame in every caller and eats into the JIT's inlining budget for no benefit, so the raw dereference stays.