- Zef interpreter achieves 16x speedup on ScriptBench1 via tagged values.
- Closes 35x gap to CPython 3.10 on Intel Core Ultra 5 135U.
- Yolo-C++ port unlocks 67x potential for PC apps.
Zef's fast dynamic language interpreter achieves 16x speedup on ScriptBench1 benchmarks. It uses tagged values and NaN boxing, according to the Zef team on zef-lang.dev. Tests run on Intel Core Ultra 5 135U with 32GB RAM. The original Zef trailed CPython 3.10 by 35x and Lua 5.4.7 by 80x.
These gains slash execution times for PC software prototyping. Zef averaged 30 interleaved runs per benchmark for reliable results.
Tagged Value Representation Boosts 64-Bit Efficiency on PC Hardware
Zef packs integers, doubles, and pointers into 64-bit values. Integers occupy the low 32 bits. Doubles use NaN tagging with a shift of 0x1000000000000. This draws from JavaScriptCore.
Pointers start above 0x100000000. The design eliminates dynamic type checks and heap allocations. PC applications benefit in tight loops and simulations on Intel Core Ultra processors.
WebKit engineer David Barnett details the mechanics in the WebKit blog.
Implement in C++:
1. Define a `uint64_t` union for tagged values. 2. Mask integers: `raw & 0xFFFFFFFF`. 3. Check doubles: `(raw & tag_mask) == double_tag`. 4. Extract doubles: `reinterpret_cast<double>(uintptr_t(raw + offset))`.
Small scripts execute faster without branch predictions.
NaN Tagging Accelerates Doubles on Core Ultra CPUs
NaN tagging embeds doubles directly without pointers. Zef applies an offset of 0x1000000000000 to raw bits. Integers fit in 32 tagged bits.
This reduces cache misses on Intel Core Ultra 5 135U. The N-Body benchmark shows clear gains. Lua.org's benchmark suite provides Lua 5.4.7 baselines.
Implementation steps:
1. Include `<cmath>` for NaN operations. 2. Define `constexpr uint64_t double_offset = 0x1000000000000ULL;`. 3. Box double: `reinterpret_cast<uint64_t>(&d) ^ double_offset`. 4. Unbox: Apply reverse XOR. 5. Guard with `std::isnan`.
Performance now rivals Lua on 32GB PC setups.
30 Interleaved Runs Deliver Reliable ScriptBench1 Results
Zef randomizes 30 benchmark runs to counter JIT warmup and GC noise. ScriptBench1 covers Richards (task simulation), DeltaBlue (constraint solver), N-Body (physics), and Splay (tree operations).
Interleaving ensures fairness on Core Ultra 5 135U. The Zef team recommends geometric means and medians, per zef-lang.dev.
Replication guide:
1. Shuffle benchmark sequence. 2. Time multiple iterations. 3. Average across 30 runs. 4. Report median times.
This validates the 16x speedup. A partial Yolo-C++ port reaches 67x.
Detailed ScriptBench1 Benchmarks Show Per-Test Gains
ScriptBench1 stresses real-world dynamic language workloads. Optimizations yield consistent speedups.
- Benchmark: Richards · Original Zef vs CPython 3.10: 32x slower · Optimized Zef Speedup: 15x faster · Original Zef vs Lua 5.4.7: 75x slower
- Benchmark: DeltaBlue · Original Zef vs CPython 3.10: 38x slower · Optimized Zef Speedup: 17x faster · Original Zef vs Lua 5.4.7: 85x slower
- Benchmark: N-Body · Original Zef vs CPython 3.10: 35x slower · Optimized Zef Speedup: 16x faster · Original Zef vs Lua 5.4.7: 80x slower
- Benchmark: Splay · Original Zef vs CPython 3.10: 34x slower · Optimized Zef Speedup: 16x faster · Original Zef vs Lua 5.4.7: 78x slower
- Benchmark: Average · Original Zef vs CPython 3.10: 35x slower · Optimized Zef Speedup: 16x faster · Original Zef vs Lua 5.4.7: 80x slower
Data from Zef team benchmarks on zef-lang.dev. PC developers gain embeddable fast dynamic language interpreters.
Hardware Implications: Core Ultra Efficiency and Cost Savings
Intel Core Ultra 5 135U packs 12 cores (2P + 8E + 2LPE), up to 4.4 GHz boost. Intel's ARK database (ark.intel.com) lists 15W base TDP and 55W turbo.
Zef's tagged values maximize this hardware. Execution times drop, cutting CPU utilization up to 94%. Local PC workflows speed up without cloud dependency.
For PC software firms, 16x faster prototyping shortens development cycles. Developers run more scripts per dollar of Core Ultra silicon.
Cost Efficiency Boosts PC Developer Value
Core Ultra 5 135U sells for $309 USD MSRP, per Intel pricing. Local Zef execution beats cloud costs.
AWS t3.micro charges $0.0104 USD per hour, per AWS EC2 pricing page (aws.amazon.com/ec2/pricing/on-demand/). Zef's 16x speedup saves $100s monthly on heavy prototyping.
This elevates Intel hardware price-performance for software teams.
Boosting PC Development with Zef's 16x Speedup
Zef transforms prototyping on Intel hardware. Scripts finish in seconds, not minutes.
Efficiency shines in cache and 32GB RAM setups. Follow these steps:
1. Clone ScriptBench1 suite. 2. Add tagged values. 3. Benchmark 30 runs. 4. Profile hotspots.
Yolo-C++ hints at 67x peaks. Zef elevates fast dynamic language interpreters for PC applications, per Zef team analysis.
Frequently Asked Questions
What is tagged value representation in fast dynamic language interpreters?
Tagged values pack integers, doubles, and pointers into 64-bit words. Zef uses 32-bit integers and NaN-offset doubles. This cuts type checks and allocations on PC hardware.
How does ScriptBench1 test dynamic language interpreters?
ScriptBench1 includes Richards, DeltaBlue, N-Body, and Splay benchmarks. Zef averages 30 interleaved runs on Intel Core Ultra 5 135U with 32GB RAM. Results show 16x optimized speedup.
Why choose NaN tagging for doubles in interpreters?
NaN tagging stores doubles directly in tagged values via offsets like 0x1000000000000. JavaScriptCore inspired Zef's approach. It avoids pointer overhead for faster PC simulations.
What hardware runs Zef interpreter benchmarks?
Intel Core Ultra 5 135U with 32GB RAM hosts tests. 64-bit tagged values optimize for this PC processor. Speedups reach 16x over baseline.
