Skip to content

Preserve live cache entries and reduce list update allocation - #587

Open
niemyjski wants to merge 11 commits into
perf/in-memory-list-snapshotfrom
feature/pr582-preserve-list-expiration
Open

niemyjski wants to merge 11 commits into
perf/in-memory-list-snapshotfrom
feature/pr582-preserve-list-expiration

Conversation

@niemyjski

@niemyjski niemyjski commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Stacked on #582. Preserve live cache entries when incoming values expire during preparation, reclaim expired stored entries atomically, and reduce list-update allocation while preserving custom-calculator contracts. The refreshed parent also rejects conditional replacements that expire before publication.

Validation: Release build/format passed; 1,922 cache tests passed (11 skips). Combined core: 2,493 passed (22 skips); fresh Redis: 778 passed (18 skips), including all 42 required contracts. Fresh binary API checks passed. Exact-head hosted CI: PR and push passed (2,455 tests, 22 skips each).

Before merge/release: performance acceptance and existing merge/release holds remain. Durable provider registrations and the RabbitMQ sample dependency correction remain separate work. No fresh non-Redis runtime coverage is claimed. The first combined run hit an existing short-expiration timing failure; focused and full reruns passed, but the timing weakness remains.

Verification and implementation details

Published head: f891a9b0808cdea5585ce393b78be1827b78c6ed; exact incorporated #582 parent: 439e0d328abb2fb56d26df34decee5ec4e385521. Main be10785cfed4e1850350dfaa024e1c3f25b7fac7 is included. The refresh preserves the prior child fixes and merges the parent's tested expired-replacement correction. Only adjacent skill documentation conflicted; both guarantees were retained.

Final-head Release build passed with one existing ASPIRE010 warning. Cache execution: 1,933 cases, 1,922 passed, 11 existing skips, zero failures/errors. All nine inherited conditional-replacement regressions and all nine expired-stored-entry reclamation cases passed. Changed-file formatting and whitespace checks passed. The reclamation fix previously reproduced retained memory in all nine cases before routing expired preparations through the atomic update path.

Existing custom calculators still receive concrete dictionaries. The additive read-only option requires support for ordinary dictionaries and immutable read-only views. Oversized fallback estimates obey MaxEntrySize. Cloned reads preserve incremental list writes; uncloned raw reads retain existing shared-value behavior. Sparse storage and lazy enumeration have allocation regression coverage.

Historical October 25 measurements for the compatible custom-calculator path, cloning disabled: 3.28x time/37x allocation versus main at 1,000 items; 6.70x/318x at 10,000 items. These timings were not rerun because this refresh leaves list/sizing code unchanged. The read-only option avoids the dictionary copy but does not eliminate immutable-update allocation. This remains an explicit compatibility/performance decision.

Combined validation on October 28 incorporates #570 0aa9d680, #580 64a4fa6a, #582 439e0d32, #586 3a888094 and this head. The resulting source tree 83733043e2a0b4cca7fca9b9a2a27ca4273f53d8 exactly matches the retained October 27 combined build/test inputs. Its Release build and full-suite results were reused rather than duplicated; no synthetic branch was pushed.

  • Full core: 2,515 cases, 2,493 passed, 22 existing skips, zero failures/errors on full rerun. The initial run failed ScopedInMemoryCacheClientTests.ListAddAsync_WithExpiration_SetsExpirationCorrectly, whose short wall-clock expiry window elapsed before the live assertion. It passed in all seven fixtures on focused rerun. The actual CacheLockProvider probe also preserved the live value/TTL/size, threw LockException and kept RenewalCount at zero.
  • Fresh Microsoft APICompat 10.0.402 against verified exact-main binaries: combined Foundatio net8/net10 and TestHarness net10 passed with parameter-name checks and no suppressions. Binary compatibility does not remove intentional runtime behavior changes.
  • Fresh Redis 8.10.2: 796 discovered/executed cache/lock cases, 778 passed, 18 existing skips, zero failures/errors. All 30 lock cases and 12 additional direct/scoped cache cases explicitly passed. Provider-output core/TestHarness DLL hashes match the checked combined binaries.
  • Redis checkout: main 06668733, existing registration PR Bump Microsoft.Extensions.Hosting from 3.1.1 to 3.1.2 #191 ae79c527 patch, and six shared cache-contract Fact overrides in each direct/scoped fixture. These are isolated test overlays, not provider-main registrations. Source-reference build passed with zero warnings/errors. Dedicated loopback-only Redis was removed afterward.
  • The October 23 all-provider source build is historical, not current-head proof. It required an isolated RabbitMQ AppHost MessagePack 2.5.303 pin; unmodified provider source was not corrected by that validation. The core sample advisory correction is included in this PR.

Both hosted runs passed at the exact published head: 2,477 total cases, 2,455 passed, 22 skipped and zero failed. The ordinary push workflow published CI packages successfully; release-package publication was skipped. No manual release or main merge occurred.

@niemyjski niemyjski changed the title Preserve list expiration when an indexed add changes no items Preserve list expiration and custom size accounting Oct 13, 2026
@niemyjski
niemyjski marked this pull request as ready for review October 13, 2026 04:39
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-28T05:09:00.352738Z
We couldn’t complete this review. Comment @codex review to try again.
f891a9b New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@niemyjski niemyjski changed the title Preserve list expiration and custom size accounting Preserve list expiration, cloning performance, and size limits Oct 15, 2026
@niemyjski niemyjski changed the title Preserve list expiration, cloning performance, and size limits Preserve list state and opt into read-only custom sizing Oct 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f13dca9648

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Foundatio/Caching/InMemoryCacheClient.cs Outdated
@niemyjski niemyjski changed the title Preserve list state and opt into read-only custom sizing Preserve live cache entries and reduce list update allocation Oct 15, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

This branch has not been deployed

No deployments
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.

1 participant