Skip to content

add -v phase timing and gate .ll write behind -v/-g#497

Open
cs01 wants to merge 1 commit intomainfrom
build-speedup
Open

add -v phase timing and gate .ll write behind -v/-g#497
cs01 wants to merge 1 commit intomainfrom
build-speedup

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Apr 12, 2026

Summary

  • Adds a one-line phase breakdown (parse=Xms sema=Yms codegen=Zms ir-write=Wms llvm=Vms link=Ums total=Tms) printed at the end of chad build -v, so next time a compile is mysteriously slow you can see where the time goes instead of guessing.
  • Stops writing the 38 MB .ll artifact to disk on every build. It's now only written under -v, -g, or ir subcommand — the cases where you'd actually want to read it. .build/ stays clean.

Why

chad build src/chad-native.ts takes ~27s. I suspected the .ll disk write was a chunk of that; turns out it's 10ms. The real answer (from the new phase line) is that LLVM -O2 optimization owns ~92% of the time. Good to know — and cheap to keep the instrumentation around so we don't have to re-derive it.

Example output under -v:

phases: parse=278ms sema=5ms codegen=1173ms ir-write=10ms llvm=24579ms link=573ms total=26621ms

Test plan

  • npm run verify:quick passes (tsc + stage 0 + stage 1 + unit tests)
  • chad build foo.ts (no flags) produces no .ll file and no phase line
  • chad build foo.ts -v writes .ll and prints phase line
  • chad build foo.ts -g writes .ll (debug path)
  • CI green

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 12, 2026

Benchmark Results (Linux x86-64)

Benchmark C ChadScript Go Node Bun Place
Binary Trees 1.540s 1.213s 2.726s 1.274s 1.048s 🥈
Cold Start 1.2ms 1.0ms 1.3ms 29.6ms 12.8ms 🥇
Fibonacci 0.908s 1.409s 1.753s 3.380s 2.056s 🥈
File I/O 0.084s 0.092s 0.087s 0.166s 0.180s 🥉
JSON Parse/Stringify 0.004s 0.005s 0.015s 0.015s 0.007s 🥈
Matrix Multiply 0.490s 0.809s 0.530s 0.437s 0.426s #5
Monte Carlo Pi 0.448s 0.439s 0.457s 2.594s 6.483s 🥇
N-Body Simulation 1.753s 2.260s 2.286s 2.350s 3.317s 🥈
Quicksort 0.246s 0.283s 0.242s 0.297s 0.261s #4
SQLite 0.323s 0.371s 0.396s 0.400s 🥈
Sieve of Eratosthenes 0.015s 0.027s 0.020s 0.042s 0.035s 🥉
String Manipulation 0.008s 0.045s 0.016s 0.039s 0.030s #5

CLI Tool Benchmarks

Benchmark ChadScript grep node xxd Place
Hex Dump 0.431s 0.993s 0.144s 🥈
Recursive Grep 0.026s 0.012s 0.108s 🥈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant