Plan: Capture Vec<u8> migration baselines for the default codec path (10.2.1) - #654
Plan: Capture Vec<u8> migration baselines for the default codec path (10.2.1)#654leynos wants to merge 3 commits into
Conversation
|
Warning Your free Security trial is over. An organization admin can activate billing to continue. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Reviewer's GuideAdds a detailed execution plan document for roadmap item 10.2.1, defining how to capture allocation, copied-byte, throughput, and latency baselines on the default codec path, including clarified copy locations, measurement strategy, instrumentation design, verification plan, and milestone breakdown — with no code changes yet. Flow diagram for invariant and measurement outputsflowchart TD
Start[Run default-path probe]
Warmup[Warm-up iteration]
Scope[Measure scoped production work]
Validate{Allocator installed and no thread escape?}
Invariants[Assert stable invariants]
Numbers[Record environment-stamped measurements]
Render[Render generated Markdown region]
End[Baseline document]
Start --> Warmup --> Scope --> Validate
Validate -->|No| Error[Reject measurement]
Validate -->|Yes| Invariants --> Render
Validate -->|Yes| Numbers --> Render
Render --> End
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Add `docs/execplans/10-2-1-capture-baselines.md`, a draft execution plan for capturing allocation, copied-byte, throughput, and latency baselines across inbound decode, middleware pass-through, request hooks, and outbound encode on the default codec path. The draft records the reconnaissance behind the design, notably that the "final default-path copy" named by the roadmap and ADR-010 is not where the phrase suggests: `LengthDelimitedFrameCodec::wrap_payload` is the identity function and `Bytes::from(Vec<u8>)` takes ownership without copying, so the cost lies in the `Vec<u8>` that `Serializer::serialize` must materialize. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Rework the baseline plan so it asserts invariants and merely records measurements, rather than committing absolute numbers to tests. Cargo Dependabot runs daily with auto-merge, and allocation counts are properties of bincode, bytes, tokio-util, and the toolchain as much as of wireframe, so a committed figure would have become a rubber stamp. Drop the proposed Verus proof and Kani harness. Roadmap section 15 owns prover bring-up, including the `verus/` entry point that revision 1 proposed to occupy, and the machinery was aimed at counter arithmetic when the instrument's realistic failure mode is misattribution. Fix six defects that would not have compiled or would have measured the wrong thing: `parse_envelope` is private to its module; the before-send hooks live on `WireframeClient`, not `RequestHooks`, and need a transport to reach; the outbound shim would have leaked `pub(crate)` `EncodedFrame` through a public signature; the middleware stage had no seam and would have been re-implemented; `wireframe_testing` enables only `testkit` and cannot see `test-support`; and `Stage` and `PayloadClass` lack the `Ord` the report's sort requires. Correct three claims about the default path. `Bytes::from(Vec<u8>)` allocates a control block even though it does not copy; `LengthDelimitedEncoder::encode` performs a second payload-sized copy that item 11.1.2 cannot remove; and middleware pass-through boxes a future per call, so it is not allocation-free. Also record that CI does not run `make test`, that `default-members` excludes `wireframe_testing` from it, and add an escape detector and an installation check to the instrument, whose two silent failure modes both report the zero that also signals success. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Rebasing onto main brought commit a31c01a, which upgraded Criterion from 0.5.1 to 0.8.2 and migrated the existing benches off the deprecated `criterion::black_box` re-export, together with serde, serde_json, and futures bumps. Update the plan's timing milestone to import `black_box` from `std::hint`, and record the upgrade as decision D-12. The API the plan relies on -- `iter_custom`, `Throughput::Bytes`, `Throughput::Elements`, and `BenchmarkId` -- is unchanged across the upgrade. Note the churn itself in `Surprises and discoveries`: four dependency-affecting commits reached main inside a single day, which is the cadence decision D-6 anticipates and the reason the plan asserts invariants rather than committed allocation figures. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
b14f0f8 to
f8fc5cf
Compare
Summary
Draft ExecPlan for roadmap item 10.2.1 — capture allocation, copied-byte,
throughput, and latency baselines for inbound decode, middleware pass-through,
request hooks, and outbound encode on the default codec path.
Plan document:
docs/execplans/10-2-1-capture-baselines.mdThis PR is documentation only. No Rust source, tests, build configuration,
or dependency manifests are touched. The plan requires approval before
implementation begins.
The central design decision
The plan separates two kinds of artefact:
payload-sized allocation" — are asserted by tests. They survive a dependency
bump and invert exactly when item 11.1.2 lands.
with a full environment stamp and are explicitly not asserted.
The reason is
.github/dependabot.yml: Cargo updates run daily withauto-merge configured. Allocation counts are properties of
bincode,bytes,tokio-util,libstd, and the toolchain as much as ofwireframe, so acommitted figure would have gone red on bot PRs until re-blessing became
reflex — destroying the before-and-after comparability that items 10.2.2,
11.2.3, and 13.2.1 need.
Substantive finding: the roadmap names the wrong copy
Reviewers should look at this first, because it changes what item 11.1.2 must
do. The roadmap and ADR-010 describe "the final default-path
Vec<u8>copybetween serialization and
FrameCodec::wrap_payload". That phrase names twooperations that do not copy, and misses two costs that do.
Free on the default codec:
LengthDelimitedFrameCodec::wrap_payload(src/codec.rs:283) is theidentity function;
type Frame = Bytes(:262).Bytes::from(Vec<u8>)(src/app/outbound_encoding.rs:36) takes ownership ofthe vector's buffer.
Not free:
Serializer::serializereturnsVec<u8>(src/serializer.rs:67-71), sobincodeallocates a vector and copies the payload into it. This iswhat item 11.1.2 can remove.
Bytes::from(Vec<u8>)heap-allocates a 24-byteSharedcontrol block whenlen != capacity(bytes-1.12.1/src/bytes.rs:947-967) — the normal case,because
bincodegrows its output amortized.LengthDelimitedEncoder::encode(src/codec.rs:248-257) delegates totokio_util, which copies the payload again into theFramedwritebuffer. This is outside
encode_message_frame, and item 11.1.2 cannotremove it.
A baseline scoped to
encode_message_framewould therefore record roughly halfthe outbound payload traffic, and item 10.2.2 would set thresholds against it.
The plan measures the framed encoder as a fifth row and ships a correction to
docs/roadmap.md:475-477and:491-492plus ADR-010 as its first, standalonecommit.
Review process
A six-lens design review (structural integrity, alternatives, measurement
validity, interface contracts, operational failure modes, long-term viability)
returned revise on the first draft. Every finding below was verified
against the code before being acted on.
Dropped from the draft:
docs/roadmap.md:583-718is adedicated formal-verification phase; item 15.1.4 adds
make kani/make verus, 15.3.1 adds the first Kani harnesses, and 15.5.2 adds theverus/proof modules the draft proposed to occupy. The machinery was also aimed at
counter arithmetic, whereas this instrument's realistic failure mode is
misattribution. Property tests and a seeded-fault control attack that
directly.
instagate over live measurements, in favour of a snapshot over fixedsynthetic rows that tests the renderer's format only.
Defects fixed (each would have failed to compile or measured the wrong thing):
parse_envelopeis a bare privatefnatsrc/app/inbound_handler.rs:74invoke_before_send_hooksis onWireframeClientatsrc/client/messaging.rs:335EncodedFrameispub(crate)atsrc/app/outbound_encoding.rs:18src/app/frame_handling/response.rs:41-55wireframe_testingcannot seetest-supportwireframe_testing/Cargo.toml:16enables onlytestkitOrdto sort byStageandPayloadClassderive neitherCaption: defects found by the design review and verified against the code.
Two false premises in the draft were also corrected: CI does not run
make test(.github/workflows/ci.ymlrunscheck-fmt,lint,markdownlint,nixie, andtest-workflow-contracts, with Rust testsreaching CI only via a coverage action), and
Cargo.toml:15setsdefault-members = ["."], somake testwould not buildwireframe_testing'stests either. All invariant tests therefore live in the root crate's
tests/.The plan also reuses the repository's existing pointer-identity idiom for
zero-copy assertions (
src/codec/tests.rs:63-71,:195-232,:236-245)rather than inventing a new one.
Scope tightened from six milestones to five, and the tolerance from 32 files
and 2,500 lines to 20 and 1,400 — matching the completed 9.6.1 plan.
Validation
make markdownlint(including the typos en-GB-oxendict chain) andmake nixieboth pass. No Rust gates were run because no Rust changed.
Follow-ups recorded, not actioned
src/app/codec_driver.rs:1-12documents that the frame pipeline appliesprotocol
before_sendhooks, but no such invocation was located inFramePipeline::process(:56-71). To be confirmed in Stage A; an issue ifit is a genuine defect.
docs/repository-layout.mdis referenced byAGENTS.md:41-43, thedocumentation style guide, and the roadmap, but does not exist.
References
docs/roadmap.md:472-474docs/frame-vec-u8-inventory.md🤖 Generated with Claude Code
Summary by Sourcery
Add a reviewed execution plan for establishing migration baselines on the default codec path.
Enhancements:
Documentation:
docs/execplans/10-2-1-capture-baselines.md.