Repository navigation
[AUTOMATED] perf: reduce CLI cold startup overhead - #558
Merged
Merged
Conversation
Avoid a function call per SLA byte while preserving chunk and EOF checks. Fifty interleaved fresh-process runs on macOS arm64, with warm filesystem cache and identical output: fauxware text 97.43 -> 89.28 ms, JSON 84.93 -> 78.40 ms, functions 82.83 -> 75.52 ms; Thumb JSON 52.62 -> 48.69 ms. Datatests 675/675, stages 749/749, check-spec and catalog pass. Release kuna-base tests: 194 passed. Full workspace: 6403 passed; 14 UPX-fixture tests fail because the host denies/removes the packed witness. UPX is outside this change; its external deletion is not staged. Co-authored-by: TRAE CLI <[email protected]>
…updates Keep boundary-crossing and EOF reads on the checked byte path. Seventy interleaved fresh-process runs against the preceding commit on macOS arm64 (warm filesystem cache, identical output): fauxware text 90.65 -> 88.15 ms, JSON 79.18 -> 76.51 ms, functions 76.84 -> 74.48 ms; Thumb JSON 49.32 -> 47.76 ms. Datatests 675/675, stages 749/749, check-spec and catalog pass. Release kuna-base: 195 passed. Full workspace: 6404 passed, with the same 14 failures caused by the missing UPX witness; all other tests in those three targets pass when only those fixture-dependent tests are excluded. No UPX code, fixture, or expectation is changed. Co-authored-by: TRAE CLI <[email protected]>
Transfer full packed chunks without copying or allocating each one; copy only the partial tail to preserve NUL and EOF padding semantics. Sixty interleaved fresh-process runs against the previous commit on macOS arm64, warm filesystem cache: fauxware JSON 78.31 -> 74.77 ms, functions 75.15 -> 71.94 ms, Thumb JSON 48.06 -> 46.20 ms. Output is exact. Datatests 675/675, stages 749/749, check-spec and catalog pass. Release base/SLEIGH tests: 504 passed. Workspace: 6410 passed and the same 14 missing-UPX-fixture failures, outside the requested scope. 27 CLI success/error cases and 34875 valid/mutated/truncated packed streams agree with the original path. No UPX changes are included. Co-authored-by: TRAE CLI <[email protected]>
`ingest_owned` re-derived `end_ingest`'s pad byte and end position inline; call `end_ingest` instead, so the padding contract keeps one definition and the two ingest paths cannot drift. The SLA/packed-decoder prose sat between the "0.1 The two tiers" heading and its own first paragraph, and described an optimization rather than the decoder. Move it beside the paragraph that resolves the specs tree and state the invariants it rests on: chunk boundaries are not observable, the byte extent and NUL termination are unchanged, and a boundary-reaching read stays on the cursor that detects end-of-stream. Restore the C++ `FormatDecode::ingestStream` anchor the new doc comment dropped. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Y9qJyRdQu6vTqagaeSp4ef
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.
What improves
A fresh CLI process spends less time loading the SLEIGH spec, and emits exactly
the same bytes. From the repository root:
Interleaved fresh-process pairs against the unpatched tree, output asserted
equal on every run:
decompile --jsondecompile(text)functions --json(medians, Linux x86-64, warm filesystem cache; 80 pairs on macOS arm64 gave
84.8 -> 77.2 ms for the first row.) The saving is a fixed startup cost, so it is
the whole of a short command and invisible in a long one.
The change
chunk's slice in one step instead of one call per byte. A read that reaches
the chunk's end stays on the byte cursor, which is where end-of-stream is
detected — no bounds or EOF check is skipped — and that cursor is now inlined.
FormatDecodehands the inflated buffer toPackedDecodeinstead of copyingit into 1 KiB chunks; only the trailing partial chunk is copied, to carry the
padding terminator. The chunk boundaries move; the ingested bytes, the NUL
termination and the byte at which the stream ends do not.
Tests
New cases cover integers at every chunk edge, owned-vs-borrowed ingestion
equality, the leading chunk not being copied, truncated-integer errors, a
fast-path/byte-cursor cross-check, and SLA header, truncation, checksum and NUL
handling.
make test675/675,make test-stages776/776,make test-cli127/127,make test-ghidra,make rust-test(6500 passed, 0 failed),make check-spec(strict) and
kuna catalog --checkall pass.decompile-all --jsonisbyte-identical — stdout, stderr and exit code — against 173 fixture binaries
spanning x86-64, i386, ARM, Thumb, ELF and PE.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Y9qJyRdQu6vTqagaeSp4ef