Repository navigation
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Pre-routing authentication authority reuse and the documented write-overload regression require final human review.
No open issues 🎉
What changed in this PR
Building on #49, this PR lets identical authenticated GETs reuse completed responses before routing. Reused authority is bounded by SQLite generation, signed-cookie validity, cache lifetime and activity deadlines.
Changes:
- Adds early response lookup with conservative eligibility checks and controlled cookie effects.
- Extends cache metadata and regression coverage for authority invalidation, request variants and cookie behavior.
- Adds reproducible workload benchmarks documenting read gains and write-overload tradeoffs.
[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or rungh pr ready --undo.
Click "Ready for review" or rungh pr readyto reengage.
| File | Description |
|---|---|
| README.md | Documents early authority reuse and fallback behavior. |
| plans/cached-response-pr-validation.md | Records validation, benchmarks and deployment limitations. |
| crates/kit/tests/http.rs | Tests panic handling after asynchronous suspension. |
| crates/kit/src/request.rs | Reduces authority-normalization allocations and adds tests. |
| crates/kit/src/front/handler.rs | Supplies unit metadata for public cached responses. |
| crates/kit/src/front/cache.rs | Supports application metadata within the cache budget. |
| crates/kit/src/adapter.rs | Removes redundant action-future boxing. |
| crates/campfire/src/response_cache/tests.rs | Tests generation observation, authority boundaries and admission rules. |
| crates/campfire/src/response_cache.rs | Implements early lookup, bounded authority and response admission. |
| crates/campfire/src/concerns.rs | Records typed room-preference effects and centralizes cookie creation. |
| crates/campfire/src/app/tests/response_cache.rs | Tests early hits, credentials, cookies and request variants. |
| crates/campfire/src/app.rs | Wires early lookup and completed-response middleware. |
| bench/README.md | Links cold and mixed workload validation. |
| bench/cached-workloads-report | Validates receipts and summarizes benchmark results. |
| bench/cached-workloads | Runs multi-user reads, audited writes and cold-key measurements. |
Review effort: Balanced
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.
Warm authenticated cache hits currently rebuild the routed context and repeat authentication/resource queries before returning an already rendered body. Reuse authority captured by a successful pipeline to return an identical admitted GET before routing.
Warm-read results: 2.46× throughput vs old Rust, 62.5% more throughput vs C#, and 59.4% less CPU/request vs old Rust (geometric means). Rust leads C# in all eight measured warm-read cases. The newer mixed-write run also exposes an overload regression, detailed below.
Review order: #49 → #50. Review only this second change. The commits are stacked; both PRs target upstream
mainbecause GitHub requires the base branch upstream and these credentials cannot create it. Merge #49 first, then update this branch onto upstreammain.Old Rust vs new Rust vs C#
Three-run median requests/second. Old Rust:
93e2a90(after the preparation optimizations). New Rust:b314160(early authenticated cache). C#:3286f07, ReadyToRun JIT. This head-to-head study predates the typed-cookie cleanup; it is not a fresh C# measurement of the current PR head.Rust throughput increased 122.9–187.9% vs old Rust and 44.6–84.7% vs C#. CPU/request fell 59.4% vs old Rust and 34.0% vs C# on geometric means. Median p99 was lower than both in every case. All 62,488,810 timed responses passed validation; no errors or invalid responses.
CPU and tail latency before/after
Separate diagnostic allocation runs measured 255.1 → 112.0 profiled objects/request (−56.1%) and 44,466 → 30,075 profiled bytes/request (−32.4%). These include background work and TTL expiry; they are not retained-memory figures or a comparable C# allocation census. CPU profiles show the routed dispatch/concerns work disappearing from the observed warm-hit stacks; SQLite generation observation remains.
Same seed, gzip, shared route/body contracts, two server CPUs and two separate generator CPUs; three alternating repetitions, 5-second warmups and 20-second windows. Release settings are unchanged. Cloud hardware differs from the published desktop/private harness. These are warm cached GET results, not a claim about every workload or language-wide superiority.
Why the C# port inspired this change
The recent devmobasa/once-campfire-dotnet port was initially faster because its
PageCacheHitMiddleware,PageTicketMemoandPageAuthorityCachecould return admitted encoded responses before routing. Rust still repeated its routed authentication and resource work before reaching its cache. This applies that architectural insight using Rust's existing verifier, immutable per-process secrets, SQLite observer and bounded response store; it does not copy C#'s dynamic key-ring mechanism.Newer two-user and mixed-write results
This run compares preparation
d7a6790against the typed-cookie early-cache implementationd4ad287; the PR has identical Rust production/test sources. Two distinct signed-in users, 16 read connections, two alternating repetitions, 5-second warmups and 20-second windows, with the same CPU allocation. Every read passed the shared contracts; all returned write IDs, creators, rooms and body tokens were independently checked in SQLite.Complete two-user mixed-workload table
Rates are write caps, not guaranteed arrivals. Only rows whose achieved write rates match within 5% in each repetition support matched-rate read comparisons. Writes target a separate room; there are no Cable subscribers.
Authentication and behavior to review
Validation and evidence
805 workspace tests pass, 11 pre-existing ignored, with
CAMPFIRE_REQUIRE_SEED=1 CAMPFIRE_REQUIRE_MEDIA_VECTORS=1; formatting, workspace/all-target Clippy with-D warningsand a normal release build pass. Tests cover revocation/token rotation, permission changes, foreign commits, delayed renders, expiry/activity boundaries, clock rollback, flash, variants and unexpected cookie effects.Current cold/mixed report and reproduction commands · Pinned warm-read study, ranges, CPU/allocation profiles and limits.