Skip to content

perf(partition): avoid blocking async lookup - #303

Merged
thomhurst merged 11 commits into
mainfrom
issue-230-partition-async-eviction
Aug 25, 2026
Merged

perf(partition): avoid blocking async lookup#303
thomhurst merged 11 commits into
mainfrom
issue-230-partition-async-eviction

Conversation

@thomhurst

@thomhurst thomhurst commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Closes #230

Summary

  • deduplicate cold partition creation with per-key task completion and add async factory/lookup APIs
  • add created/evicted lifecycle callbacks, explicit cleanup APIs, counters, metrics, and testing snapshots
  • prevent eviction callbacks from waiting on their own reserved capacity while preserving callback-before-slot-reuse ordering
  • document lifecycle behavior, eviction telemetry, and add the 1M execution bounded partition stress workload

Validation

  • dotnet build Kevlar.slnx -c Release -m:1 -nr:false — 0 warnings/errors
  • Kevlar.Tests — 994 passed on net8.0; 1,019 passed on net10.0
  • Kevlar.Chaos.Tests — 35 passed on each TFM
  • Kevlar.AllocationTests — 4 passed on each TFM
  • npm run build — Docusaurus production build passed
  • partition stress: 1,000,000 executions / 10,000 keys / maximum 1,000 retained

Benchmarks

BenchmarkDotNet 0.15.8, .NET 10.0.11, Windows 11, i7-12700K.

Benchmark Before (249b440) After (5bbba87) Allocated before/after
Capacity_Eviction 331.5 ns 326.0 ns 768 B / 768 B
Warm_Lookup 11.92 ns 0 B

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9093d309-c156-4115-8db8-ea44d041541e


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@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: 6268be1e80

ℹ️ 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/Kevlar/Internal/PartitionCache.cs Outdated

@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: 47491418c7

ℹ️ 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/Kevlar/Internal/PartitionCache.cs Outdated
Comment thread src/Kevlar/PartitionedShield.cs
Comment thread src/Kevlar/Internal/PartitionCache.cs

@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: 249b440b4d

ℹ️ 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/Kevlar/Internal/PartitionCache.cs

@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: 5bbba8757c

ℹ️ 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/Kevlar/Internal/PartitionCache.cs

@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: bd2895d0aa

ℹ️ 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/Kevlar/Internal/PartitionCache.cs
Comment thread src/Kevlar/Internal/PartitionCache.cs Outdated

@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: 779ae9029f

ℹ️ 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/Kevlar/Internal/PartitionCache.cs Outdated
@thomhurst
thomhurst force-pushed the issue-230-partition-async-eviction branch from 779ae90 to 31c2b6d Compare August 25, 2026 09:12

@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: 31c2b6d4fe

ℹ️ 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/Kevlar/Internal/PartitionCache.cs Outdated
Deduplicate cold creation with per-key task completion so async callers yield. Add lifecycle callbacks, metrics, snapshots, and bounded stress coverage.
Release the mutation gate before invoking lifecycle observers while preserving callback-before-replacement ordering.
Complete saturated cold lookups reentered from eviction callbacks without retaining them, preserving callback-before-slot-reuse ordering. Document the partition eviction metric and make its consistency test deterministic.\n\nRefs #230
Eviction callbacks create an unretained shield instead of joining a publication that cannot finish until the callback returns.
Track the creation blocked by eviction callbacks so nested same-key lookups cannot join their awaiting publisher after capacity changes.
@thomhurst
thomhurst force-pushed the issue-230-partition-async-eviction branch from 31c2b6d to e4be70b Compare August 25, 2026 09:40

@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: e4be70b181

ℹ️ 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/Kevlar/Internal/PartitionCache.cs
Comment thread src/Kevlar/Internal/PartitionCache.cs Outdated
Chain nested callback dependencies and install reservation scope before metrics so reentrant lookups cannot wait on their caller.
@thomhurst
thomhurst merged commit 4fa0eaa into main Aug 25, 2026
10 checks passed
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.

perf(partition): first-lookup dedup blocks async callers with Monitor.Wait; add eviction callbacks

1 participant