Skip to content

perf: swap writer's spread-with-deltaTime for Object.assign - #81

Closed
elicwhite wants to merge 1 commit into
perf/midi-uint8-writerfrom
perf/avoid-spread-in-writer
Closed

perf: swap writer's spread-with-deltaTime for Object.assign#81
elicwhite wants to merge 1 commit into
perf/midi-uint8-writerfrom
perf/avoid-spread-in-writer

Conversation

@elicwhite

Copy link
Copy Markdown
Owner

tsup transpiles {...ev, deltaTime: 0} to __spreadProps(__spreadValues(...))
which iterates property descriptors — ~7% of total writer profile time was
spent inside __spreadProps. Object.assign({}, ev, { deltaTime: 0 }) is a
native builtin on V8 and 2-3× faster for small objects.

Applied at the three writer sites that clone-with-delta-reset a source
event: buildUnrecognizedTrack (top-level unrecognized MIDI tracks) and
the per-track unrecognizedMidiEvents passes in buildDrumTrack and
buildFretTrack.

Measured on writer autoresearch bench (2000 charts, 8 workers):
previous: 5.710 ms mean, 4.883 ms p50, 15.040 ms p95, 5.132s wall
now: 4.566 ms mean, 4.129 ms p50, 10.424 ms p95, 4.926s wall
delta: -20.0% mean, -30.7% p95

Second run (variance check): 4.609 ms mean — stable.

0 hash mismatches, 442/442 tests still green.

Cumulative: baseline 92 ms -> 4.57 ms, 20× faster.

tsup transpiles `{...ev, deltaTime: 0}` to __spreadProps(__spreadValues(...))
which iterates property descriptors — ~7% of total writer profile time was
spent inside __spreadProps. Object.assign({}, ev, { deltaTime: 0 }) is a
native builtin on V8 and 2-3× faster for small objects.

Applied at the three writer sites that clone-with-delta-reset a source
event: buildUnrecognizedTrack (top-level unrecognized MIDI tracks) and
the per-track unrecognizedMidiEvents passes in buildDrumTrack and
buildFretTrack.

Measured on writer autoresearch bench (2000 charts, 8 workers):
  previous: 5.710 ms mean, 4.883 ms p50, 15.040 ms p95, 5.132s wall
  now:      4.566 ms mean, 4.129 ms p50, 10.424 ms p95, 4.926s wall
  delta:    -20.0% mean, -30.7% p95

Second run (variance check): 4.609 ms mean — stable.

0 hash mismatches, 442/442 tests still green.

Cumulative: baseline 92 ms -> 4.57 ms, 20× faster.
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