Repository navigation
perf(serialization): bound retained Arc buffer page caches - #11470
ReubenBond wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
The low-level concurrent pooling, reference ownership, cancellation, and finalization changes warrant final human validation.
0 open findings
What changed in this PR
Bounds Arc buffer pooling and enables zero-copy retained journal storage with safe ownership across writes, reads, cancellation, and shutdown.
Changes:
- Adds a configurable 4 MiB page-cache budget with concurrent accounting and trimming.
- Introduces retained journal-buffer ownership and stable volatile-storage snapshots.
- Adds extensive ownership, failure, concurrency, and regression tests plus documentation.
| File | Description |
|---|---|
test/Orleans.Serialization.UnitTests/ArcBufferPagePoolTests.cs |
Tests pool budgets and concurrency. |
test/Orleans.Journaling.Tests/VolatileJournalStorageOwnershipTests.cs |
Tests volatile-storage ownership. |
test/Orleans.Journaling.Tests/StateManagerStorageOwnershipTests.cs |
Tests manager I/O lifetimes. |
test/Orleans.Journaling.Tests/JournalBufferWriterOwnershipTests.cs |
Tests oversized-tail trimming. |
src/Orleans.Serialization/README.md |
Documents page pooling. |
src/Orleans.Serialization/Orleans.Serialization.csproj |
Exposes internals to journaling tests. |
src/Orleans.Serialization/Buffers/ArcBufferWriter.cs |
Implements bounded page pooling. |
src/Orleans.Journaling/VolatileJournalStorage.cs |
Adds independently retained storage pages. |
src/Orleans.Journaling/README.md |
Documents ownership behavior. |
src/Orleans.Journaling/JournaledStateManager.cs |
Uses retained storage and drains shutdown I/O. |
src/Orleans.Journaling/JournalBufferWriter.cs |
Releases oversized idle capacity. |
src/Orleans.Journaling/IRetainedJournalStorage.cs |
Defines the retained-storage capability. |
src/api/Orleans.Serialization/Orleans.Serialization.cs |
Updates the generated API surface. |
docs/site/src/content/docs/grains/journaling/runtime-behavior.md |
Documents runtime ownership semantics. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code coverage
Report-only conclusion: improved. The current-main baseline is commit Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities. The comparison remains report-only while normal line and branch variance is calibrated. Coverage details |
ae3ea82 to
e4647cc
Compare
0c667b0 to
fcecd42
Compare
Bounds the process-wide cache of free Arc buffer pages so completed workloads release excess idle backing capacity rather than accumulating it indefinitely.
ArcBufferWriter.MaxRetainedPoolBytesconfigures the aggregate free-page budget, with a default of 128 MiB. Setting zero releases already-free pages and disables retention; reducing the budget immediately trims published free pages. Concurrent returns reserve byte capacity before publication and recheck the current budget afterward, keeping the settled cache within the limit. Pages up to 1 MiB are eligible for retention; released large backing arrays return to the separately managedArrayPool<byte>.Shared. Writers and pinned readers keep ownership of active pages throughout their lifetimes. The 128 MiB default provides process-wide reuse headroom and remains configurable; it is a policy choice, not a workload-tuned benchmark result.The change is limited to three files: the Arc writer/page-pool implementation, its generated public API, and native pool-policy tests. The property's XML API documentation describes its behavior and defaults. Tests cover the exact 128 MiB default and zero budgets, reductions and increases, oversized pages, active slice preservation, late publication after a reduction, stale trim requests after an increase, and concurrent rent/return/configuration changes. The tests declare the actual CI Suite/Provider traits. The additive public property has an officially regenerated API surface and the normal Serialization Release pack passes compatibility validation.
The PR has been narrowed to pooling only, based on main
d558f4c58dc125bb83a9ca66091424d29eeeb41e. Optional journal-storage retention, the alpha storage API break and compatibility suppressions, automatic drained-tail trimming, provider adaptations, and their tests/docs are removed from this PR. Existing main journal APIs, formats, and snapshot policy are preserved. This pool bound is independent of durable messaging payload representation and requires no messaging, owned-RPC, or retained-storage prerequisite.Microsoft Reviewers: Open in CodeFlow