bench(#856): add 6 demonstrative cross-runtime workloads (json, regex, sort, typed-arrays, binary-trees, brainfuck)#879
Merged
Conversation
Broadens the cross-runtime suite beyond the original arithmetic kernels with workloads where SharpTS-compiled, Node (V8), and Bun (JSC) diverge most: json, regex, sort, typed-arrays, binary-trees, brainfuck - json/typed-arrays/binary-trees are number->number, added to the shared benchmarks/scripts/lib/algorithms.ts (also embedded by SharpTS.Benchmarks), with matching Idiomatic/Equivalent C# baselines and a new BenchmarkDotNet StarterWorkloadBenchmarks.cs (SharpTS-compiled vs native vs boxed C#). - regex/sort/brainfuck are self-contained scripts (seeded Park-Miller LCG for deterministic, cross-runtime-identical data). All six produce byte-identical results across interpreter, compiled, Node, and Bun (equal work), so any gap is pure codegen. They immediately surfaced two compiled-output gaps now tracked as #877 (Array.sort is O(n^2) insertion sort) and #878 (Float64Array element access is boxed + virtually dispatched).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #856 (perf epic). Broadens the cross-runtime benchmark suite (
benchmarks/) beyond the original 7 arithmetic kernels — which are all tuned to ~parity — with 6 workloads chosen for where SharpTS-compiled, Node (V8), and Bun (JSC) diverge most: builtin hot paths, data-parallel numeric code, GC/allocation pressure, and a dispatch-heavy macro program.Workloads added
algorithms.ts+ BDNFloat64Arrayalgorithms.ts+ BDNalgorithms.ts+ BDNnumber → number, added to the sharedbenchmarks/scripts/lib/algorithms.ts(also embedded bySharpTS.Benchmarks), with matchingIdiomaticCSharp(native) +EquivalentCSharp(boxedobject?) baselines and a new BenchmarkDotNetStarterWorkloadBenchmarks.cs(SharpTS-compiled vs native C# vs boxed C#).No harness plumbing changed —
run-benchmarks.ps1globsscripts/*.ts,format-results.ps1auto-renders, andBenchmarkSwitcherauto-discovers the new classes.Results (compiled vs Node, largest param)
The new workloads immediately surfaced two compiled-output gaps, now filed:
Array.sort(comparator)is O(n²) insertion sort — ~998× slower than Node, slower than our own interpreter #877 —Array.sort(comparator)emits an O(n²) insertion sort (slower than our own interpreter).Float64Array/TypedArray element access is boxed + virtually dispatched (no typed fast path) — 24–101× slower than Node #878 —Float64Array/TypedArray element access is boxed + virtually dispatched (no typed fast path).Verification
dotnet build -c Release— clean (0 warnings).--compile(3BENCH:lines each).run-benchmarks.ps1completes with all 4 runtimes producing output for all 40 cases.MemoryDiagnoserconfirms binary-trees allocates ~6.7× the native version.Purely additive benchmark/fixture code — no interpreter, compiler, or runtime changes, so Test262 / TS-conformance are unaffected.