perf(round27): NextCloud PROPFIND oc:id per-row buffer, contact JSONB write direct-serialize
Two behaviour-preserving allocation cuts (benches/ROUND27.md), each with a
counting-allocator BEFORE/AFTER gate that rolls back if AFTER does not allocate
fewer than BEFORE:
- H1 NextCloud PROPFIND: the streaming page loops built oc:id as a fresh String
per child (format_oc_id -> format!("{:08}{}", id, instance)). Add
format_oc_id_into(&mut buf, id, svc) and compute into one oc_buf reused across
the page (next to the existing href buffer) — 1 String/row -> 0. 998->0
per-row allocs on a 500-row page, 2.16x wall. The write fns still take
Option<&str>, so no signature change; oc:id bytes identical. Scoped to the two
PROPFIND page loops (the hot directory-listing path); REPORT/trashbin deferred.
- P2 contact create/update: bind sqlx::types::Json(&dtos) (Encode runs to_writer
straight into the JSONB buffer) instead of serde_json::to_value(&dtos) + bind,
which built a throwaway Value DOM per JSONB column. Write-side twin of ROUND23
J1. 21->2 allocs, 4.68x wall for a 3-entry column. Behaviour-preserving:
to_value sorts keys and direct serialize keeps struct order, but Postgres
normalizes JSONB key order so the stored value is identical (verified via psql:
'{...alpha...}'::jsonb = '{...struct...}'::jsonb -> t), and reads decode by
field name; the etag comes from the domain entity, not the stored JSONB.
Adds bench_round27_micro. Verified: cargo fmt clean, cargo clippy --features
bench -D warnings clean (real exit), cargo test --lib --features bench = 529
passed / 0 failed.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L8gs91AhmazoxMsDcNk3KT
This commit is contained in:
+11
@@ -358,6 +358,17 @@ name = "bench_micro_allocs"
|
||||
path = "examples/bench_micro_allocs.rs"
|
||||
required-features = ["bench"]
|
||||
|
||||
# Round-27 battery ────────────────────────────────────────────────────────────
|
||||
|
||||
# Round-27 CPU/alloc micro-pack (no Postgres) — NC PROPFIND per-row oc:id String
|
||||
# → reused buffer via format_oc_id_into (H1); contact create/update JSONB write
|
||||
# through a throwaway serde_json::Value DOM → sqlx::types::Json(&dtos) direct
|
||||
# serialize (P2, the write-side twin of §J1).
|
||||
[[example]]
|
||||
name = "bench_round27_micro"
|
||||
path = "examples/bench_round27_micro.rs"
|
||||
required-features = ["bench"]
|
||||
|
||||
# Round-26 battery ────────────────────────────────────────────────────────────
|
||||
|
||||
# Round-26 CPU/alloc micro-pack (no Postgres) — drive-policy JSONB decode through
|
||||
|
||||
Reference in New Issue
Block a user