perf: round 11 finale — benchmark verdicts, geo min(uuid) rollback, ROUND11.md

- benches/ROUND11.md: final BEFORE/AFTER numbers for all 21 micro
  sections, the 5 query sections, the 4 log-writer arms, the SPA gates,
  and the two cross-round regression guards (bench_row_path 2.52x,
  bench_dto_map — both byte-identical)
- ROLLBACK (gate-caught): min(fm.file_id)::text geo-cluster cast —
  PostgreSQL has no min(uuid) aggregate; the bench section now reproduces
  the rejection and the per-row-cast original stays
- REJECTED (bench-measured): tracing-appender non-blocking writer —
  slower than sync on fast sinks (1.41M vs 0.99M ev/s, worse tail) and
  the slow-sink drain gate showed shutdown tail-loss risk for the audit
  channel; dep moved to dev-dependencies (harness only)
- RateLimiter final form: lock-free get + insert (8.0 → 6.0 allocs, wall
  neutral; and_upsert_with variant rejected at 2 365 ns)
- fix: TrashedItemParts insertion had stolen TrashedItem's derive line
  (caught by clippy --all-targets)
- grant_role enum values corrected in the queries bench

Validation: cargo fmt + clippy --all-features --all-targets -D warnings
clean; cargo test --workspace 524 passed / 0 failed; frontend npm run
check 0 errors + vitest 306 passed (1 pre-existing round-7 wall-clock
gate flaked only under concurrent Rust-build CPU contention; passes in
isolation)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ABhTEHuGujvwoodh67Kga7
This commit is contained in:
Claude
2026-07-18 22:46:20 +00:00
parent 221c1f31b0
commit b01633791b
6 changed files with 269 additions and 108 deletions
+6 -3
View File
@@ -8,14 +8,17 @@
//! Sections (all pure CPU, no Postgres):
//! 1. REST download `FileDto` dead clone vs mime/size capture + move
//! 2. Single-resource GET/HEAD `Last-Modified`: chrono `to_rfc2822()`
//! vs `common::fmt::rfc2822_utc` stack render (gate: byte-identical)
//! vs `common::fmt::rfc2822_utc` stack render (gate: byte-identical).
//! VERDICT: header port REJECTED — the chrono String is already the
//! terminal allocation; only body-emit sites benefit.
//! 3. `/status.php` poll: rebuild `json!` + serialize vs `OnceLock<Bytes>`
//! (gate: byte-identical)
//! 4. NC chunk-upload session PROPFIND: `push_str(&format!)` + chrono
//! per chunk vs `with_capacity` + `write!` + stack dates
//! (gate: byte-identical XML)
//! 5. RateLimiter: 2 key allocs + entry+insert vs 1 alloc + single
//! `and_upsert_with` (gate: identical allow/deny + counts)
//! 5. RateLimiter: 2 key allocs + entry+insert vs (a) `and_upsert_with`
//! [REJECTED: slower + more allocs] vs (b) lock-free get + insert
//! [ADOPTED] (gate: identical counter sequences)
//! 6. CSRF header token: `to_string` vs borrow compare (gate: same bool)
//! 7. Thumbnail ETag: `{:?}` Debug enums vs `as_str` + push (gate: bytes)
//! 8. Recent-handler id: `Uuid::to_string` vs stack `encode_lower`
+17 -14
View File
@@ -312,7 +312,13 @@ async fn direct_grant_query(pool: &PgPool, subject: Uuid, cal: Uuid) -> bool {
)
.bind(vec!["user"])
.bind(vec![subject])
.bind(vec!["reader", "contributor", "manager", "owner"])
.bind(vec![
"owner",
"editor",
"contributor",
"commenter",
"viewer",
])
.bind("calendar")
.bind(cal)
.fetch_optional(pool)
@@ -546,11 +552,15 @@ async fn section_geo(pool: &PgPool, s: &Seed, passes: usize) {
}
tx.commit().await.expect("commit geo seed");
let mut b = geo_query(pool, s.owner, "min(fm.file_id::text)").await;
let mut a = geo_query(pool, s.owner, "min(fm.file_id)::text").await;
b.sort_by(|x, y| x.3.cmp(&y.3));
a.sort_by(|x, y| x.3.cmp(&y.3));
gate("cluster rows identical", a == b);
// REJECTED BY GATE: PostgreSQL has no `min(uuid)` aggregate — the
// planned `min(fm.file_id)::text` (cast per cluster) fails to parse, so
// the per-row-cast original stays. Verify the rejection reproducibly
// and record the BEFORE for the doc.
let min_uuid_err = sqlx::query("SELECT min(fm.file_id)::text FROM storage.file_metadata fm")
.fetch_optional(pool)
.await
.is_err();
gate("min(uuid) unsupported → AFTER rejected", min_uuid_err);
let (ms_b, _) = timed(passes.min(60), || async {
geo_query(pool, s.owner, "min(fm.file_id::text)")
@@ -558,14 +568,7 @@ async fn section_geo(pool: &PgPool, s: &Seed, passes: usize) {
.len()
})
.await;
let (ms_a, _) = timed(passes.min(60), || async {
geo_query(pool, s.owner, "min(fm.file_id)::text")
.await
.len()
})
.await;
println!(" BEFORE min(file_id::text) p50 {ms_b:.3} ms");
println!(" AFTER min(file_id)::text p50 {ms_a:.3} ms");
println!(" BEFORE min(file_id::text) p50 {ms_b:.3} ms (AFTER rejected — see gate)");
let _ = sqlx::query("DELETE FROM storage.files WHERE drive_id = $1 AND name LIKE 'geo-%'")
.bind(s.drive)