PeaBox Lab › PeaLang › Learn › Chapter 34 › Lesson 2

Part V — The Modern Experience Layer · Chapter 34 · Lesson 2 of 2

A numerics fast path you can actually use

The JIT chapter showed the skeleton; this lesson is judgment. PeaLang 3.1.39 does not ship an automatic numeric JIT with guaranteed speedups. There are three separate, measurable paths: conservative bytecode optimization, a limited fast interpreter, and a small register-level instruction rewriter. Choose them by measurement.

What actually gets faster

No part of the 3.1.39 source supports a blanket “two to ten times faster” claim. Report the number you measured on your artifact.

What does not

The bigger lever for analytics: Arrow and DuckDB (v1.6.0)

let rows = [
  {"city": "North", "amount": 10},
  {"city": "South", "amount": 20}
]
let info = analysis.backend_info()
let backend = "python"
if info.duckdb_available {
  backend = "duckdb"
}
let plan = analysis.create_query_plan(rows, backend)
let projected = plan.select(["city", "amount"])
let limited = projected.limit(10)
let result = limited.collect()
print result
print info

The registered Arrow helpers are preferred_backend, available_backends, backend_info and create_query_plan. A plan exposes filter, select, limit, sort, aggregate, collect, explain and optimize; filter expects a Python callable, so keep that step in host tooling unless you have a bridge. Only "duckdb" selects DuckDBBackend during execution; any other value uses PythonBackend. This is a lazy plan over rows, not a SQL parser. Use it for data-shaped work, and use the bytecode or fast-interpreter paths for scalar code.

Measurement discipline

let baseline_source = read("baseline.pea")
let candidate_source = read("candidate.pea")
let baseline = analysis.benchmark_vm(baseline_source, 100)
let candidate = analysis.benchmark_vm(candidate_source, 100)
print baseline.median_ms
print baseline.p95_ms
print candidate.median_ms

analysis.benchmark_vm(source, iterations=100) returns iterations, min_ms, max_ms, mean_ms, median_ms and p95_ms. There is no analysis.benchmark_compare: the Python-level vm_optimizer.benchmark_compare is not registered in analysis and returns a modeled 0.8x estimate with a fixed 1.25 speedup, so it is not a measured comparison. Archive baselines so regressions surface as deltas. If a benchmark or parity call fails, PeaLang errors use pealang-error-v1; inspect the ErrorValue record, the code, cause and context fields on PeaError, or the record returned by build_error(), rather than string-matching.

Version note

Version note. The local source is PeaLang 3.1.39. bytecode_optimizer.py declares OPTIMIZER_VERSION = "3.1.38" and CORE_RELEASE_FROZEN_AT = "3.1.37". jit_compiler.py is still a skeleton; its docstring describes a future v2.2 native emitter, but emit_native returns a marker blob. analysis.loop_unroll_hint is a suggestion helper from vm_optimizer.py: it reports should_unroll and an estimated_speedup, and does not rewrite code. OptimizationHints.loop_unrolling is not read by OptimizeInstructions.

Where this leaves the 1.0-era performance story

Guided practice

← Previous Next →