Skip to content

[Autoloop: tsb-perf-evolve]#303

Draft
github-actions[bot] wants to merge 8 commits into
mainfrom
autoloop/tsb-perf-evolve
Draft

[Autoloop: tsb-perf-evolve]#303
github-actions[bot] wants to merge 8 commits into
mainfrom
autoloop/tsb-perf-evolve

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Goal

Evolve Series.sortValues to match pandas performance on a 100k-element benchmark. Fitness = tsb_mean_ms / pandas_mean_ms (lower is better; < 1.0 = tsb faster than pandas).

Current best: fitness 21.048 (tsb ≈ 112ms / pandas ≈ 5.3ms)

This Iteration (c042)

Change: Add module-level _permBuf: number[] and _outBuf: number[], grown lazily. In sortValues, reuse them instead of allocating new Array<number>(n) and new Array<T>(n) on every call.

Hypothesis: The benchmark makes 55 calls (50 measured + 5 warmup) × 2 large JS-array allocations = ~110 MB of array allocations that trigger GC. Both Index and Series constructors copy their inputs via Object.freeze([...data]), so module-level buffer reuse is safe. Eliminating these per-call allocations should reduce GC pauses and lower mean_ms.

Program

Related issue: #189 | State file: tsb-perf-evolve.md

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

Generated by Autoloop · ● 35.7M ·

…to reduce GC pressure

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

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…e j*2/j*3 multiplications in partition loop

Operator: exploitation | Parent: c042 | Island: 3 (non-comparison/radix)

Replace per-element multiplications in the main partition loop with stride
counters (fsi += 2, rxBase += 3). This eliminates 2 integer multiplications
per non-NaN numeric element (~190k multiplications for n=100k, 5% NaN).
Also removes the redundant typeof guard from the NaN check, saving one
branch per element in the common all-numeric case.

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

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor Author

Commit pushed: c2a5165

Generated by Autoloop

@github-actions
Copy link
Copy Markdown
Contributor Author

Commit pushed: cf28509

Generated by Evergreen — PR Health Keeper

@github-actions
Copy link
Copy Markdown
Contributor Author

🌱 Evergreen: Merged main

The PR branch was 13 commits behind main. I merged origin/main into autoloop/tsb-perf-evolve — clean merge, no conflicts.

  • New HEAD: cf28509cba68b5164877964fe63d40852586473f

CI should now trigger on the updated branch. No code changes were made — this was purely a merge-up.

Generated by Evergreen — PR Health Keeper · ● 3.1M ·

mrjf and others added 2 commits May 13, 2026 10:51
…tructors

When _permBuf / _outBuf were larger than n (from a prior larger sort),
[...perm] and [...outData] in the Index/Series constructors spread all
elements including stale tail entries, producing results with wrong length.
Truncating to n via .length = n ensures only the n written elements are
spread.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor Author

Commit pushed: 53fdd35

Generated by Evergreen — PR Health Keeper

@github-actions
Copy link
Copy Markdown
Contributor Author

Evergreen: CI fix pushed 🔧

Root cause: The _permBuf / _outBuf buffer-reuse optimisation (introduced in c042) had a bug: when the shared buffers were larger than the current sort size n, they were reused without truncation. The Index and Series constructors both do Object.freeze([...data]), which spreads all elements including the stale tail, producing outputs with wrong length.

Fix: Added an else branch that sets _permBuf.length = n and _outBuf.length = n when the existing buffer is large enough to reuse, ensuring only the n freshly-written elements are spread.

All 21 failing Series.sortValues tests should now pass.

Generated by Evergreen — PR Health Keeper · ● 12.4M ·

@github-actions
Copy link
Copy Markdown
Contributor Author

Commit pushed: 817cace

Generated by Evergreen — PR Health Keeper

@github-actions
Copy link
Copy Markdown
Contributor Author

Evergreen: merged main into branch

This branch was 2 commits behind main. I merged origin/main cleanly (no conflicts — only workflow config files changed) and pushed the merge commit.

CI should now run on the updated branch. No code changes were needed.

Generated by Evergreen — PR Health Keeper · ● 3.1M ·

@github-actions github-actions Bot mentioned this pull request May 13, 2026
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