Skip to content

add total build time to -v output, harden dispatchNamedObject#497

Merged
cs01 merged 1 commit intomainfrom
build-speedup
Apr 13, 2026
Merged

add total build time to -v output, harden dispatchNamedObject#497
cs01 merged 1 commit intomainfrom
build-speedup

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Apr 12, 2026

Summary

  • chad build -v foo.ts now appends ` in Xms` to the existing `Compiled: ...` line. Cheap way to see total build time without reaching for the shell's `time`. No change at default verbosity.
  • One-line workaround in `MethodCallGenerator.dispatchNamedObject` to harden it against a pre-existing native-compiler false positive in `checkMissingReturns`. Needed because any edit to `compileNative`'s body shifts AST layout enough to trip the false positive on that function — same class of bug we've hit before on `transformExpression`. The extra trailing `return null;` after the switch-with-default short-circuits `mrAllReturn` on the first reverse-iteration step and makes the function immune to future layout shifts.

Why the two changes ship together

They're not logically coupled, but they're operationally coupled: landing the timing change alone reliably trips the `dispatchNamedObject` false positive. Verified by bisection — even a 2-line timing edit is enough.

Test plan

  • `npm run verify:quick` passes locally (tsc + Stage 0 build + Stage 1 self-build + Stage 1 smoke + unit tests)
  • `chad build foo.ts` — no behavior change
  • `chad build foo.ts -v` — `Compiled: foo in 26621ms` appears
  • CI green

Root cause note

The underlying `checkMissingReturns` / `mrAllReturn` codegen bug is documented in memory (`native-missing-returns-false-positive.md`) for future sessions. This PR is a workaround for that specific function, not a fix for the root cause. The real fix lives in `src/semantic/safety-checks.ts` `mrAllReturn` and is a separate effort.

@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.379s 1.251s 2.700s 1.177s 0.967s 🥉
Cold Start 1.0ms 0.8ms 1.2ms 27.0ms 9.1ms 🥇
Fibonacci 0.814s 1.472s 1.562s 3.180s 1.976s 🥈
File I/O 0.116s 0.092s 0.088s 0.199s 0.175s 🥈
JSON Parse/Stringify 0.004s 0.005s 0.017s 0.015s 0.007s 🥈
Matrix Multiply 0.446s 0.696s 0.613s 0.374s 0.327s #5
Monte Carlo Pi 0.389s 0.410s 0.404s 2.248s 6.049s 🥉
N-Body Simulation 1.665s 2.121s 2.201s 2.395s 3.249s 🥈
Quicksort 0.214s 0.244s 0.213s 0.262s 0.226s #4
SQLite 0.348s 0.404s 0.415s 0.399s 🥉
Sieve of Eratosthenes 0.016s 0.028s 0.020s 0.040s 0.036s 🥉
String Manipulation 0.008s 0.046s 0.016s 0.036s 0.028s #5

CLI Tool Benchmarks

Benchmark ChadScript grep node xxd Place
Hex Dump 0.427s 0.994s 0.130s 🥈
Recursive Grep 0.019s 0.010s 0.097s 🥈

`chad build -v foo.ts` now appends " in Xms" to the "Compiled: ..." line.
Useful when something feels slow and you want to know without reaching
for the shell's `time`. No behavior change at default verbosity.

The one-line `return null;` added to `MethodCallGenerator.dispatchNamedObject`
after the switch-with-default is a workaround for a native-compiler false
positive in checkMissingReturns: any edit to compileNative's body shifts
AST layout enough to trip it on dispatchNamedObject. The extra trailing
return makes the function immune. Node compiler accepts the original code
fine; this only affects the self-hosted path.
@cs01 cs01 changed the title add -v phase timing and gate .ll write behind -v/-g add total build time to -v output, harden dispatchNamedObject Apr 13, 2026
@cs01 cs01 merged commit 7ce2f75 into main Apr 13, 2026
13 checks passed
@cs01 cs01 deleted the build-speedup branch April 13, 2026 04:35
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