Skip to content

perf: optimize shared state legend mount#2100

Draft
xuefei1313 wants to merge 1 commit into
developfrom
agent/optimize-shared-state-legend-mount
Draft

perf: optimize shared state legend mount#2100
xuefei1313 wants to merge 1 commit into
developfrom
agent/optimize-shared-state-legend-mount

Conversation

@xuefei1313

Copy link
Copy Markdown
Contributor

Summary

  • Batch inherited shared-state scope resolution while mounting a detached graphic subtree, avoiding repeated recursive scope binding.
  • Preserve custom parent-tree synchronization hooks and subsequent add/remove-child behavior.
  • Compile static DiscreteLegend state definitions once per render and reuse the compiled definitions across compatible item text graphics.
  • Scope the legend cache to one render and reset it on rerender/release, so it does not retain caller-owned state definitions.

Root cause

A 100-category legend creates many item groups and child graphics. During first mount, each append repeatedly resolved and synchronized the same shared-state scope; static selected/unSelected definitions were also compiled repeatedly per legend item.

Performance

For the VChart pie.small.100 case, warmed Chrome traces show a median initial render of approximately 37–38 ms, compared with 46.906 ms before the Core optimization (about 19–21% lower).

Validation

  • packages/vrender-core: targeted state and batch-mount tests (29 passing).
  • packages/vrender-components: DiscreteLegend tests (5 passing).
  • rush compile -t @visactor/vrender-components.
  • Pre-push rush test --only tag:package (all package test operations passed).

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