llmiterate performance notes
Workflow
Profile command:
bun --cpu-prof --cpu-prof-md --cpu-prof-dir=__bench__/profiles --cpu-prof-name=baseline.cpuprofile.md __bench__/bench.ts
Benchmark command:
bun __bench__/bench.ts
/tmp/go-bin/benchstat __bench__/baseline.txt __bench__/optimized.txt
Profile findings
Baseline CPU profile hotspots:
- path filtering dominated scans:
shouldIncludePath, regex excludes, andtoSlashsplit/join - parser spent avoidable time rebuilding marker regexes and checking Markdown extension per line
Optimizations
- compile path filters once per runtime
- split simple
dir/**excludes intoSetroot-dir checks / prefix checks before regex fallback - add
shouldIncludeCompiledPath()for hot scan paths - make
toSlash()allocation-free when path is already slash-normalized - cache marker regex by normalized marker list
- compute Markdown-file status once per parse
Benchstat
│ __bench__/baseline.txt │ __bench__/optimized.txt │
│ sec/op │ sec/op vs base │
ParseNoMarkers 73.71µ ± ∞ ¹ 57.10µ ± ∞ ¹ ~ (p=0.333 n=1+5)
ParseSomeMarkers 82.60µ ± ∞ ¹ 70.85µ ± ∞ ¹ ~ (p=0.333 n=1+5)
ParseMarkdownFences 110.88µ ± ∞ ¹ 80.38µ ± ∞ ¹ ~ (p=0.333 n=1+5)
PathFilterCompiled 3227.5µ ± ∞ ¹ 763.7µ ± ∞ ¹ ~ (p=0.333 n=1+5)
geomean 216.1µ 125.5µ -41.90%
¹ need >= 6 samples for confidence interval at level 0.95
Note: baseline was captured before optimization; optimized has 5 samples. Confidence is limited but direction/magnitude is clear.