Skip to content

perf(datatree): cache module refs and flatten child recursion#4908

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

perf(datatree): cache module refs and flatten child recursion#4908
lukecotter wants to merge 1 commit into
tabulator-tables:masterfrom
lukecotter:perf/datatree

Conversation

@lukecotter

Copy link
Copy Markdown
Contributor

Summary

Reduce allocation in data-tree child traversal. Behaviour-preserving.

Changes

  • Cache the filter/sort module references and the dataTreeFilter/dataTreeSort option flags at initialize() instead of re-resolving them on every traversal.
  • getChildren recurses into a single shared accumulator (_collectChildren) so each descendant is pushed exactly once, instead of allocating and re-copying an array at every level of the tree.

Benchmark (Node)

  • getChildren over ~250k tree nodes (depth 4, fanout 6): +38% (1.6×)

Tests

Full unit suite green; DataTree spec updated to reflect that module references are now read at initialize time (realistic mock table).

Cache filter/sort module references and options at initialize. getChildren recurses into a single shared accumulator (_collectChildren) so each descendant is pushed once, instead of allocating and re-copying an array at every level.
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