Skip to content

Latest commit

 

History

History
101 lines (80 loc) · 4.96 KB

performance.md

File metadata and controls

101 lines (80 loc) · 4.96 KB

Performance Viability

This contract does not claim RubyHx or RailsHx outperforms handwritten Ruby, Rails, another compiler, or another type system. Stable evidence instead answers a smaller operational question: do representative authoring and generated-runtime paths finish with bounded time, memory, and output growth on the maintained stack?

Run the repeatable workload set from the repository root:

npm run benchmark:stable

The command writes tmp/stable-benchmark.json and prints a human summary plus the same JSON to stdout. The canonical production job runs it with --require-rails after the todo app production smoke has prepared its bundle. Use --samples 1 for a quick local implementation check; canonical evidence always uses the default three samples.

Measured Workloads

Workload What it measures
rubyhx_cli_compile Clean compilation of the maintained multi-file pure-Ruby CLI/library example.
railshx_server_compile Clean compilation of the RailsHx todo app's Haxe/HHX server source to Ruby, Rails artifacts, and ERB.
railshx_client_compile Clean compilation of the todo app's Haxe client through Genes to JavaScript and source maps.
rubyhx_cli_startup Startup and real fixture execution of the generated Ruby CLI.
rails_production_boot Production boot of the already prepared generated Rails app through rails runner.

Each sample records elapsed wall time and peak child RSS when the host's /usr/bin/time supports it. Compiler workloads also record generated regular file count and bytes. The JSON includes the exact Git SHA, OS, architecture, CPU, available memory, CI image metadata, and Node/npm/Haxe/Ruby versions.

“Cold” means the first clean-output invocation in that process; repeat samples still clean their outputs but may benefit from operating-system caches. RubyHx does not currently promise a persistent incremental compiler server, so this contract does not relabel repeated clean builds as incremental compilation. The RailsHx development watcher still improves the edit loop materially by staying idle on unchanged inputs, removing duplicate initial compiles, and debouncing each affected HXML target. Those rebuilds remain direct Haxe invocations; a future managed haxe --wait claim needs separate lifecycle and performance evidence.

Profiling a Slow Compile

The cheapest profile is Haxe's own timer table with per-function macro timing. Add these two flags to any RubyHx compile command:

haxe <the usual arguments> --times -D eval-times

--times prints the phase table. -D eval-times adds one row for each compiler function that runs in the macro interpreter, with its call count.

Haxe 4.3.7 on Apple Silicon under-reports the time(s) column by a factor of about 41.67. A build that takes 10 seconds of wall time shows a total of about 0.24. Do not quote these seconds. Use the table only for:

  • the % and p% columns, which give each row's share of the total and of its parent row
  • the # column, which gives the call count

For absolute time, measure the wall time of the whole command, for example with /usr/bin/time -l. Compare a change against an unmodified checkout with interleaved runs, because machine load changes the result more than most compiler changes do.

Two patterns have caused large costs in this compiler:

  • Ref.get() in a hot path. In the macro interpreter each call encodes the whole declaration again. Ref.toString() returns the type path or field name without that work. reflaxe.helpers.ModuleTypeHelper.getCommonData keeps a per-build memo for the cases that need more than the name.
  • Lowering one sub-expression more than once. If each level of a nested expression lowers its child two or three times, compile time grows exponentially with the nesting depth. The string_call_chain snapshot case compiles a 40-call chain to catch this.

Regression Policy

The script's reviewed limits are broad absolute caps intended to catch runaway compiler work, memory growth, or output explosions. Any cap breach fails the canonical production job and therefore blocks publication. Small wall-time changes and high percentage spread do not fail the lane because GitHub-hosted runner scheduling and hardware vary; maintainers inspect that evidence when reviewing a release candidate.

This contract deliberately has no benchmark service, historical dashboard, or tight relative timing gate. It also does not duplicate the Rails request, job, browser, asset, or production correctness suites. Those mandatory exact-SHA lanes remain the behavioral evidence. A future public claim about latency, throughput, allocations, JIT behavior, or relative speed must first add a purpose-built workload and an appropriately stable threshold.

At release-candidate review, record the exact canonical run URL and its JSON summary alongside the other release evidence. Numbers from developer machines are useful for investigation but are not substituted for the canonical Ubuntu lane.