Skip to content

perf(sort): bound insertion sort work - #76

Merged
BridgeAR merged 1 commit into
mainfrom
BridgeAR/2026-10-13-stringify-sort
Oct 13, 2026
Merged

BridgeAR merged 1 commit into
mainfrom
BridgeAR/2026-10-13-stringify-sort

Conversation

@BridgeAR

Copy link
Copy Markdown
Owner

Disordered objects with up to 200 keys can spend most of their serialization time shifting keys during insertion sort.
Nearly ordered keys retain the insertion path.

A shuffled 200-key object uses 16.6 us instead of 45.6 us, a 64% CPU reduction on Node 26.3.1 (V8 14.6.202.34-node.20).
Measurements use 50,000 warmup calls and seven alternating trials, with the fastest and slowest trials removed.

Drive-by fix: Mark intentional invalid-option assertions for TypeScript.

Disordered objects with up to 200 keys can spend most of their serialization
time shifting keys. A shuffled 200-key object uses 16.6 us instead of 45.6 us
on Node 26.3.1 (V8 14.6.202.34-node.20), a 64% CPU reduction. Measurements
use 50,000 warmup calls and seven alternating trials, with the fastest and
slowest removed. Nearly ordered keys retain the insertion path.

Drive-by fix: Mark intentional invalid-option assertions for TypeScript.
@BridgeAR
BridgeAR marked this pull request as ready for review October 13, 2026 05:15
@BridgeAR
BridgeAR merged commit 8ed2781 into main Oct 13, 2026
5 checks passed
@BridgeAR
BridgeAR deleted the BridgeAR/2026-10-13-stringify-sort branch October 13, 2026 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant