Skip to content

perf(core): clone row template and slice active rows#4904

Draft
lukecotter wants to merge 1 commit into
tabulator-tables:masterfrom
lukecotter:perf/core-allocations
Draft

perf(core): clone row template and slice active rows#4904
lukecotter wants to merge 1 commit into
tabulator-tables:masterfrom
lukecotter:perf/core-allocations

Conversation

@lukecotter

Copy link
Copy Markdown
Contributor

Summary

Two small allocation reductions on core hot paths, both behaviour-preserving.

Changes

  • Row.createElement clones a shared template element (cloneNode(false)) instead of running createElement + classList.add + setAttribute for every row.
  • RowManager.setActiveRows copies with Array.slice() instead of Object.assign([], activeRows) (and drops a dead double self-assignment). Object.assign([], arr) falls onto V8's generic property-copy path and is dramatically slower than slice() on large arrays; this runs on every pipeline pass.

Benchmarks (Node, 250k rows, median of trials)

  • Row.createElement 250k: +41% (1.7×)
  • setActiveRows copy: +99% (≈166×) — removes a ~23ms hitch per pipeline pass on large datasets.

Tests

Full unit suite green. No behaviour change.

Row.createElement clones a shared template element instead of running createElement + classList.add + setAttribute per row. RowManager.setActiveRows copies with Array.slice() instead of Object.assign([], ...) (and drops a dead self-assignment), avoiding the slow generic-property copy path on large datasets.
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