Skip to content

feat(journaling): configure volatile journal snapshot thresholds - #11471

Merged
ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-volatile-journal-snapshot-policy
Oct 10, 2026
Merged

ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-volatile-journal-snapshot-policy

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Volatile journal storage currently requests compaction based on its stored segment count. That makes snapshot frequency implicit and provides no byte-based policy for larger appends.

Add VolatileJournalStorageOptions and default/named provider configuration. Each journal requests a snapshot when either its successful append count or appended encoded bytes reaches the configured threshold. The deliberate defaults are 100 appends or 1 MiB (1,048,576 bytes), replacing main's >10 stored-segment trigger. Positive int append limits and positive long byte limits are supported.

Providers capture the configured limits at construction. Named/default options pipelines apply before that boundary; the store owns journal-wide counters shared across handles and isolated across journals and providers. The state manager observes the request before its next write, materializes the current state snapshot, awaits replacement, and acknowledges the write. Successful snapshot replacement or deletion resets both counters; snapshot bytes are excluded from append history. Delete/recreation resets history. The existing retirement test explicitly selects its required snapshot frequency.

Threshold checks and counter updates use constant-time accounting under the existing store lock. The stored list count and each copied byte-array length fit in int, bounding the appended-byte sum below long.MaxValue. Retained memory includes the latest snapshot, encoded append history including the crossing append, and provider bookkeeping. Storage continues to copy main's borrowed input buffers and preserves existing format dispatch (V1 marker 1 and the V0 reader).

Include deterministic exact-threshold, cancellation, snapshot/reset, multi-segment borrowed-input, isolation, option-validation, concurrent shared-handle, separate options-pipeline capture, and JSON/binary replay cases. Source-backed configuration guidance and the generated additive API surface accompany the implementation. Normal Release packing passes the released compatibility baseline unchanged.

This standalone extraction was carved from original base 48f3aaa47fc18123db4109063af591f315e6f9cb through source 9c1ef0f2feb258c1764de5f408d89c53e7e63f9f (initial policy commit bb124aaf6b5bb294f492a44941b90202a841b818), and is now rebased onto main b3b76e2ab207f00e664e0167cd733800cd60379d. The latest repository contract/performance review retained the focused policy design and added explicit construction/concurrency guarantees. Retained-storage/page-pool optimization, writer/manager ownership changes, hooks, dictionary lifecycles, messaging, timers, and BufferPackage stay outside this PR.

Microsoft Reviewers: Open in CodeFlow

Copilot AI balanced review requested due to automatic review settings October 10, 2026 16:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the described policy and includes comprehensive validation and behavioral coverage.

0 open findings

What changed in this PR

Adds configurable append-count and byte thresholds for volatile journal snapshots.

Changes:

  • Adds validated default and named-provider snapshot options.
  • Tracks and resets per-journal append counters.
  • Adds documentation, API surface updates, and comprehensive tests.
File Description
src/​Orleans.Journaling/​VolatileJournalStorageOptions.cs Defines threshold options and validation.
src/​Orleans.Journaling/​VolatileJournalStorage.cs Implements per-journal counters and snapshot requests.
src/​Orleans.Journaling/​JournalingHostingExtensions.cs Registers default and named options.
src/​Orleans.Journaling/​README.md Documents threshold behavior.
src/​api/​Orleans.Journaling/​Orleans.Journaling.cs Updates the generated public API surface.
docs/​site/​src/​content/​docs/​grains/​journaling/​configuration.md Adds configuration guidance.
docs/​site/​src/​content/​docs/​grains/​journaling/​snippets/​journaling/​JournalingConfiguration.cs Adds a configuration example.
test/​Orleans.Journaling.Tests/​VolatileJournalStorageProviderTests.cs Tests boundaries, resets, cancellation, and isolation.
test/​Orleans.Journaling.Tests/​KeyedJournalingRegistrationTests.cs Tests named options and replay integration.
test/​Orleans.Journaling.Tests/​StateManagerTests.cs Preserves the retirement test’s compaction frequency.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage

Metric Pull request Current main Variance
Lines 83.37% (118,391 / 142,004) 83.39% (118,367 / 141,948) -0.0160 pp
Branches 72.91% (35,172 / 48,238) 72.94% (35,177 / 48,226) -0.0285 pp

Report-only conclusion: regressed.

The current-main baseline is commit b3b76e2ab2 and uses the same reviewed coverage matrix.

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

Copilot AI balanced review requested due to automatic review settings October 10, 2026 19:11
@ReubenBond
ReubenBond force-pushed the rb-volatile-journal-snapshot-policy branch from 7d9abac to f180255 Compare October 10, 2026 19:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the documented policy and has comprehensive behavioral coverage.

0 open findings

🧠 Review effort: Balanced

@ReubenBond
ReubenBond merged commit d558f4c into dotnet:main Oct 10, 2026
94 checks passed
@ReubenBond
ReubenBond deleted the rb-volatile-journal-snapshot-policy branch October 10, 2026 22:40
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