Skip to content

[Autoloop: tsb-perf-evolve]#249

Merged
mrjf merged 1 commit into
mainfrom
autoloop/tsb-perf-evolve
Apr 30, 2026
Merged

[Autoloop: tsb-perf-evolve]#249
mrjf merged 1 commit 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.

Goal

Evolve Series.sortValues to be as fast as (or faster than) pandas Series.sort_values on a 100k numeric benchmark. Metric: tsb_mean_ms / pandas_mean_ms (lower is better; < 1.0 means tsb beats pandas).

Current best metric: 27.999 (c003 — 155ms vs 5.56ms pandas)
Program issue: #189
State file: tsb-perf-evolve.md

Iteration 28 — Merge partition + radix-init into one pass

Combines the pre-partition scan and the separate radix key-initialisation loop into a single O(n) pass. Also switches fvals to compact (sequential) indexing and gathers output directly from srcIdx after the radix sort, eliminating an intermediate O(finCount) copy-back step.

Mechanism: saves ~2 × O(n) typed-array loop passes per sortValues call — fewer iterations through memory, better cache utilisation, less work for the JIT.

Generated by Autoloop · ● 5M ·

Combines the pre-partition loop and the separate radix key-init loop into a
single O(n) pass, saving one full O(n) loop. Also uses compact fvals indexing
(fvals[finCount] instead of fvals[origIdx]) for sequential memory access, and
gathers directly from srcIdx after the radix sort, eliminating the intermediate
copy-back-to-finSlice step (another O(finCount) loop saved).

Net savings per call at n=100k: two fewer O(n) typed-array loop passes.

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

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mrjf mrjf marked this pull request as ready for review April 30, 2026 05:44
@mrjf mrjf merged commit 92a095f into main Apr 30, 2026
12 checks passed
@github-actions github-actions Bot deleted the autoloop/tsb-perf-evolve branch April 30, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant