Fix MLPA tail increment; add cmdline options to Garnet BDN#1872
Open
TedHartMS wants to merge 1 commit into
Open
Fix MLPA tail increment; add cmdline options to Garnet BDN#1872TedHartMS wants to merge 1 commit into
TedHartMS wants to merge 1 commit into
Conversation
TedHartMS
commented
Jun 13, 2026
Contributor
- Changed MultiLevelPageArray to use PageOffset for its tail and incrementing, fixing a rare lost-id
- Add cmdline options to Garnet BDN, replacing the environment-variable approach
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Tsavorite’s MultiLevelPageArray allocation scheme to use a packed (Page, Offset) tail (via PageOffset) to avoid rare lost/duplicated ids under concurrent page growth and retry paths, and modernizes the Garnet BenchmarkDotNet harness to accept command-line options instead of environment variables.
Changes:
- Refactors
MultiLevelPageArray<TElement>to use aPageOffset-backed tail withInterlocked.Add/Exchangecoordination for page turns (including a DEBUG-only AddPage failure injection hook). - Adds/updates Tsavorite recovery tests to stress the OOM rewind-and-retry path deterministically in DEBUG builds.
- Adds BenchmarkDotNet CLI parsing for framework selection and operations parameter selection (
--frameworks/--fw,--opparams/--op).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| libs/storage/Tsavorite/cs/test/test.recovery/ObjectIdMapTests.cs | Renames allocation loop terminology and adds a DEBUG-only multi-thread OOM stress test using the new MLPA injection hook. |
| libs/storage/Tsavorite/cs/src/core/Utilities/SimpleConcurrentStack.cs | Updates Clear parameter naming to “retainedPageCount” to align with MLPA terminology. |
| libs/storage/Tsavorite/cs/src/core/Utilities/MultiLevelPageArray.cs | Core change: packed tail (PageOffset) allocation protocol + page growth path refactor + DEBUG-only failure injection hook. |
| libs/storage/Tsavorite/cs/src/core/Allocator/PageUnit.cs | Clarifies PageOffset.Offset semantics via doc comment. |
| libs/storage/Tsavorite/cs/src/core/Allocator/ObjectIdMap.cs | Adjusts assertions and clear-retention constants to match MLPA’s new Count/tail semantics. |
| benchmark/BDN.benchmark/Program.cs | Adds custom CLI arg consumption and wires it into BDN configuration; replaces env-var behavior. |
| benchmark/BDN.benchmark/Operations/OperationsBase.cs | Reworks operation parameter gating to be driven by CLI-selected flags (and adds a helper to set all flags). |
Comment on lines
+309
to
+313
| for (var page = 0; page <= lastPageIndex; page++) | ||
| { | ||
| Array.Clear(book[chapter], 0, MultiLevelPageArray.ChapterSize); | ||
| if (chapter > retainedChapterCount) | ||
| book[chapter] = null; | ||
| Array.Clear(book[page], 0, MultiLevelPageArray.PageSize); | ||
| if (page > retainedPageCount) | ||
| book[page] = null; |
Comment on lines
333
to
336
| { | ||
| var maxPage = chapter < lastChapterIndex ? MultiLevelPageArray.ChapterSize : lastPageIndex; | ||
| for (var page = 0; page < maxPage; page++) | ||
| var maxBlock = page < lastPageIndex ? MultiLevelPageArray.PageSize : lastBlockIndex; | ||
| for (var block = 0; block < maxBlock; block++) | ||
| { |
Comment on lines
+339
to
343
| book[page][block] = default; | ||
| } | ||
| if (chapter > retainedChapterCount) | ||
| book[chapter] = null; | ||
| if (page > retainedPageCount) | ||
| book[page] = null; | ||
| } |
Comment on lines
+21
to
+22
| // Extract our custom CLI options (--runtime / --ops) before forwarding remaining args to BDN. | ||
| var passthroughArgs = ConsumeCustomArgs(args); |
Comment on lines
+95
to
+97
| BDN.benchmark.Operations.OperationsBase.SetAllParams(false); | ||
| var ops = Program.bdnOpParam.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Select(p => p.ToLower()).ToArray(); | ||
| foreach (var op in ops) |
Comment on lines
+58
to
61
| #if DEBUG | ||
|
|
||
| #else | ||
| .Run(args, new BaseConfig()); | ||
| #endif |
Comment on lines
43
to
+56
| /// <summary> | ||
| /// Set by environment variable BDNRUN_OP_PARAM - determines if running with only "None" parameters (no ACLs, no AOF) or with all combinations of parameters | ||
| /// Clear and set all args before selecting the specific ones to be set by cmdline arg --bdnOpParam | ||
| /// </summary> | ||
| internal static bool ParamsNoneOnly; | ||
| public static void SetAllParams(bool isEnabled) | ||
| { | ||
| ParamsNone = isEnabled; | ||
| ParamsACL = isEnabled; | ||
| ParamsAOF = isEnabled; | ||
| ParamsAAD = isEnabled; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Set by cmdline arg --bdnOpParam | ||
| /// </summary> |
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.