Files
Claude 7c3c59f5f8 phase0: dry run — comrak & tokei vendored, 3 attempts in ledger
Target selection (SPEC §6): comrak 0.53.0 (45c1995, BSD-2-Clause) and
tokei 14.0.0 (fa44e51, MIT/Apache-2.0); both CPU-bound with pinned
corpora (progit book 11MB; 8x replicated pinned trees, 221MB) and
committed MANIFEST.sha256 + golden-output pins + regen scripts.

Calibration: A/A null verdicts on both real workloads; taskset -c 2
pinning tightens the A/A CI from [0.938, 1.008] to [0.993, 1.008],
making the 2% accept threshold meaningful in this container.

Profiles (callgrind; perf unavailable): comrak allocator symbols 26.7%
of Ir; tokei perform_multi_line_analysis 31.7%.

Attempts (ledger + results/phase0/):
- comrak class-1 target-cpu=native: null [0.983, 1.011], rejected-bench
- comrak class-2 mimalloc swap: +4.6% [1.033, 1.058], 848 upstream
  tests green, golden byte-identical, ASan-proper clean; LSan flags
  484B in onig (reachability false-positive analysis in case study) ->
  needs-human-review per SPEC §8
- tokei class-1 fat LTO+cgu=1: +1.6% [1.003, 1.026], real but under
  the 2% bar, rejected-bench

Also: ledger-cli for manual rows, targets/ excluded from trust-layer
workspace, corpora/build artifacts gitignored, case study written.
Phase 0 exit criteria (>=10% verified win) not yet met; next
hypotheses logged in results/phase0/attempts.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EcKPWQ3MQD4NdEHwar96u2
2026-07-06 19:28:50 +00:00

40 lines
1.2 KiB
Diff

diff --git a/Cargo.toml b/Cargo.toml
index bd1dfe9..fcc70f3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -69,7 +69,7 @@ phf_codegen = "0.13"
[features]
default = ["cli", "syntect-onig", "bon"]
-cli = ["clap", "bon", "shell-words", "xdg", "fmt2io", "shortcodes", "phoenix_heex", "attributes"]
+cli = ["clap", "bon", "shell-words", "xdg", "fmt2io", "shortcodes", "phoenix_heex", "attributes", "mimalloc"]
shortcodes = ["emojis"]
phoenix_heex = []
attributes = []
@@ -107,6 +107,7 @@ clap = { version = "4", optional = true, features = [
"string",
"wrap_help",
] }
+mimalloc = { version = "0.1", optional = true }
[[example]]
name = "syntect"
diff --git a/src/main.rs b/src/main.rs
index 6c5b2a6..a439fb7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -10,6 +10,13 @@ use std::{boxed::Box, io::BufWriter};
use clap::{Parser, ValueEnum};
+// The CLI churns many small AST allocations; mimalloc services them with
+// far fewer instructions than glibc malloc. Library consumers are
+// unaffected: this only applies to the comrak binary.
+#[cfg(not(target_arch = "wasm32"))]
+#[global_allocator]
+static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
+
use comrak::options;
use comrak::{Arena, Options};
#[cfg(feature = "syntect")]