Skip to content
This repository was archived by the owner on Nov 3, 2026. It is now read-only.

[Autoloop] [Autoloop: tsb-perf-evolve] - #206

Merged
mrjf merged 2 commits into
mainfrom
autoloop/tsb-perf-evolve
Apr 24, 2026
Merged

mrjf merged 2 commits into
mainfrom
autoloop/tsb-perf-evolve

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This PR is maintained by Autoloop. Each accepted iteration adds a commit to this branch.


Program Goal

Evolve Series.sortValues so that tsb runs at least as fast as pandas on the synthetic benchmark (n=100k float64 with 5% NaN). Fitness = tsb_mean_ms / pandas_mean_ms (lower is better; < 1.0 = tsb wins).

Program Issue: #189


Iteration 2 — Float64Array parallel values for monomorphic numeric sort

Operator: Exploration (Island 1, parallel-typed-arrays × comparison)

Change: Pre-copy finite numeric values into a parallel Float64Array (fvals) during the partition pass. For all-numeric Series, the sort comparator now reads fvSlice[a]! - fvSlice[b]! (typed Float64Array subtraction) instead of (vals[a] as number|string|boolean) < (vals[b] as ...) (generic T[] access + branch comparison).

Hypothesis: Float64Array access gives the JIT a monomorphic, unboxed call site. A single FP subtraction replaces two branches per comparison. Over ~1.7M comparisons for n=100k, this should measurably reduce sort time.

For string/boolean/mixed Series the original generic comparator is used unchanged.

Baseline: Island 1 implementation (NaN pre-partition + Uint32Array indirect sort) is on main as of commit 5792af4 after PR #190 was merged.

Generated by Autoloop · ● 4M · ◷

Pre-copy finite numeric values into a parallel Float64Array (fvals) during
the partition pass. For all-numeric Series the sort comparator now reads
fvSlice[a]! - fvSlice[b]! instead of (vals[a] as ...) < (vals[b] as ...),
giving the JIT an unboxed, monomorphic Float64Array call site and replacing
two branch comparisons with a single FP subtraction per comparison.

For string/boolean/mixed Series the existing generic branch comparator is
used unchanged.

Run: https://github.com/githubnext/tsessebe/actions/runs/24830395075

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mrjf

mrjf commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

@copilot fix tests

Copilot AI commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

@copilot fix tests

Fixed in commit 8d1d4a3. I corrected the numeric fast-path indexing in Series.sortValues so values are read by original row index, and the failing sort/NaN tests now pass (bun test tests/core/series.sortValues.test.ts tests/core/series.test.ts and full bun test).

Copilot finished work on behalf of mrjf April 23, 2026 15:34
Copilot AI requested a review from mrjf April 23, 2026 15:34
@mrjf
mrjf merged commit bd00bfb into main Apr 24, 2026
9 checks passed
@github-actions
github-actions Bot deleted the autoloop/tsb-perf-evolve branch April 29, 2026 22:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants