Dogfooding oa on three zero-dependency Rust tools

After shipping the earlier v0.12.0 release of oa, I ran its profile-and-gate loop against three of my own zero-dependency, #![forbid(unsafe_code)] Rust CLIs: convto (structured data conversion and header probing), isa-audit (x86-64 and AArch64 ELF64 instruction auditing), and bincompat (ELF64 ABI and hardening batch scanning).

Each pull request started with oa profile (rootless Linux perf plus --heap-track) and then faced oa compare --check-output --pairs 11 --warmup 2 --metric pareto against main in a detached shadow worktree, enforcing exact stdout SHA-256 parity, Mann-Whitney U p <= 0.01, a 95% bootstrap confidence interval, and zero Peak RSS regression. You can inspect the underlying statistical math in the interactive oa playground.

PR / Workload Wall Time Speedup (95% CI, p) Peak RSS Output Parity
convto#21 json -> toml 1164.12 to 18.25 ms 62.14x [54.30x, 69.79x], 0.0001 Pareto clean 7/7 SHA-256
convto#21 csv -> json (50k) 62.98 to 28.87 ms 2.17x, 0.0001 66,104 to 23,000 KiB (-65.2%) SHA-256 match
isa-audit#21 libLLVM.so.23.1 317.09 to 34.93 ms 8.72x [8.35x, 9.16x], 0.0001 168,340 to 99,104 KiB (-41.1%) 9cf4151422537746..
isa-audit#21 check icelake 306.05 to 34.08 ms 9.09x [8.88x, 9.48x], 0.0001 168,296 to 100,092 KiB (-40.5%) SHA-256 match
bincompat#20 text (4,958 ELFs) 197.11 to 46.74 ms 4.21x [4.12x, 4.26x], 0.0001 77,096 to 47,480 KiB (-38.4%) 12/12 SHA-256
bincompat#20 JSON (4,958 ELFs) 309.68 to 93.96 ms 3.27x [3.16x, 3.60x], 0.0001 156,524 to 86,560 KiB (-44.7%) 12/12 SHA-256

1. convto#21: Quadratic string parsing and a Pareto RSS catch

Profiling convto exposed three scaling bugs in pure-Rust parsing and probing. In src/data.rs, JsonParser::parse_string() repeatedly re-validated UTF-8 over remaining slices in O(N^2) time, and large JSON/YAML objects ran O(K^2) linear key deduplication on every insertion to preserve override semantics. In src/info.rs, each file triggered three stat() calls and a 256 KiB read even when image headers fit inside 4 KiB.

The key guardrail catch came on iteration 1. After borrowing &str directly for bulk unescaped slicing, adding a lazy HashMap index in ObjectBuilder above 16 keys, and moving to a single fs::metadata() plus a 4 KiB stack probe, I added String::with_capacity(input.len()) to the serializer. Wall time plunged, yet oa's Pareto gate blocked the patch on a +7.3% Peak RSS regression: holding the raw input, AST, and pre-sized output string simultaneously inflated peak memory.

Dropping the input buffer before emission, streaming through a 64 KiB chunk-flushing OutBuf::streaming writer, and adding a zero-AST streaming path for csv -> json reversed the memory curve. Pinned to core 0 (--pin-core 0) with 7/7 SHA-256 identical outputs: json -> toml ran 62.14x faster (1164.12 to 18.25 ms, CI [54.30x, 69.79x], p = 0.0001), json -> yaml 60.08x (1072.40 to 17.97 ms), json -> csv 46.22x (820.28 to 17.73 ms), 5,000-key object json -> yaml 24.92x (451.89 to 17.26 ms), 50,000-row csv -> json 2.17x faster with -65.2% Peak RSS (66,104 to 23,000 KiB), and recursive info -r across 1,000 images (300 MB) 3.69x faster (71.51 to 19.36 ms).

2. isa-audit#21: 870.8M instructions/sec on libLLVM.so.23.1

Profiling /usr/lib/libLLVM.so.23.1 (148 MiB total, 78.7 MiB executable .text, 19.3M instructions) with oa profile (linux:perf plus --heap-track) showed two dominant costs: 89.7% of CPU cycles spent inside the legacy prefix loop and 242-way 1-byte opcode jump table in src/decoder.rs, and 150.7 MiB allocated loading non-executable .rodata, .eh_frame, and .data sections before ignoring them.

Keeping #![forbid(unsafe_code)], zero external crates, and Rust 1.75 MSRV, I replaced the hot paths with compile-time lookup tables and selective loading. In src/decoder.rs, constant tables (LEGACY_PREFIX_KIND, MODRM_LEN, OP1_CLASS, OP1_PACKED, OP0F_NO_PREF) drive a branchless 16-byte-window baseline fast path (decode_fast_baseline_x86). In src/decoder_aarch64.rs, a 256-entry top-byte prefilter LUT (A64_TOP_BYTE_FLAGS) classifies 210 of 256 top bytes as guaranteed baseline over chunks_exact(4).

In src/elf.rs and src/analyzer.rs, try_load_selective_elf skips non-executable sections on files >= 1 MiB, a monotonic symbol cursor (resolve_symbol_monotonic) avoids repeated binary searches, and sections >= 1 MiB scan across STT_FUNC-aligned chunks with std::thread::scope and deterministic merges. On libLLVM.so.23.1 (identical SHA-256 9cf4151422537746..), multi-core scan sped up 8.72x (317.09 to 34.93 ms, CI [8.35x, 9.16x], p = 0.0001) with -41.1% Peak RSS (168,340 to 99,104 KiB), reaching 3,389 MiB/s (870.8M insns/s). Multi-core check --target icelake ran 9.09x faster (306.05 to 34.08 ms), single-core --pin-core 0 ran 2.36x faster (304.39 to 129.18 ms, -43.1% RSS), and a synthetic 16 MiB AArch64 single-core scan ran 5.90x faster (44.03 to 7.51 ms).

3. bincompat#20: Cutting 1.29M allocations across 4,958 ELFs

Batch scanning 4,958 ELF binaries across /usr/bin and /usr/lib exposed three allocation-heavy bottlenecks under oa profile --heap-track: repeated read_cstr and Utf8Chunks walks over string tables, 1.29M heap allocations for version vectors and symbol maps, and 143 MiB of transient core::fmt JSON churn before flushing output.

Keeping zero dependencies and #![forbid(unsafe_code)], I added a 16 KiB stack head-buffer with pread64 (FileExt::read_at) and a fused single-pass scan_and_attribute_dynsym over a direct-indexed VerIndexMap in src/elf.rs. Inline 4-part small-vec storage in Version and an OnceLock cache for distro baselines eliminated repeated parsing, while DirEntry::file_type() removed extra lstat() calls during directory walks. In src/report.rs, a 256-byte JSON escape LUT and windowed 256-entry streaming emission (write_batch_scan_with_report_options) paired with bounded std::thread::scope batching preserved deterministic lowest-index error order.

Across 12/12 SHA-256 identical runs covering all five formats (Text, JSON, Markdown, SARIF 2.1.0, and github): 4,958-ELF text scan sped up 4.21x (197.11 to 46.74 ms, CI [4.12x, 4.26x], p = 0.0001, -38.4% Peak RSS) and JSON scan 3.27x (309.68 to 93.96 ms, Peak RSS 156,524 to 86,560 KiB, -44.7%). Across 1,847 ELFs in /usr/lib, check --target rhel-9 sped up 3.27x text (97.38 to 29.41 ms) and 3.00x JSON (142.84 to 48.41 ms), and diff -r across 1,847 pairs sped up 3.75x (123.38 to 33.61 ms).

4. Why three flags mattered in practice

Three flags in oa compare prevented real regressions across these PRs:

oa compare --git main \
  --build "cargo build --release" \
  --bench "./target/release/isa-audit scan /usr/lib/libLLVM.so.23.1 --format json" \
  --pairs 11 --warmup 2 --metric pareto --check-output --pin-core 0

5. Follow-up: dogfooding oa on itself (v0.13.0)

Before tagging oa v0.13.0, I pointed the same oa profile and oa compare --check-output --metric pareto workflow at oa's own reporting and statistics pipeline. Eliminating redundant string allocations and intermediate formatting buffers delivered 2.12x faster HTML report generation and 2.10x faster text output while cutting Peak RSS by 49.2% and heap allocations by 68.8%, with bit-identical SHA-256 outputs.

Limitations