r/Protos • u/guillermoamolina • 2h ago
Compile callbacks ahead of time or on first use? A measurable runtime trade-off
Moving callback compilation out of runtime execution changes an interesting performance trade-off.
Selected callback execution plans are now prepared during compilation, while Closure creation and captured bindings remain deferred until needed.
A targeted JVM benchmark with 128 samples per scenario showed:
- 28.4% lower first-execution latency for custom callback receivers.
- 8.0% lower first-execution latency for canonical Boolean receivers.
- Higher retained memory when prepared callback code remains unused.
Specialized inline execution paths remain intact, and all local regression tests pass.
The interesting question is where to draw the line between eager code preparation, lazy materialization and memory retention.
Website: https://protoslang.com
Source code: https://github.com/guillermomolina/protos