Skip to content

perf: Avoid duplicate dirty parent elements to improve performance by 2% - #1968

Merged
wang1212 merged 3 commits into
masterfrom
perf/dirty
Jul 21, 2025
Merged

perf: Avoid duplicate dirty parent elements to improve performance by 2%#1968
wang1212 merged 3 commits into
masterfrom
perf/dirty

Conversation

@Alexzjt

@Alexzjt Alexzjt commented Jul 18, 2025

Copy link
Copy Markdown
Contributor

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / Document optimization
  • TypeScript definition update
  • Refactoring
  • Performance improvement
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

💡 Background and solution

s2滚动场景下,有大量嵌套的节点会走到dirtyToRoot。排在前面的元素自下而上dirty后,排在后面的元素不需要再给父元素dirty了。

before After
image image

📝 Changelog

Language Changelog
🇺🇸 English Avoid duplicate dirty parent elements to improve performance by 2%
🇨🇳 Chinese 避免重复dirty父级元素提升2%性能

☑️ Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@changeset-bot

changeset-bot Bot commented Jul 18, 2025

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8bd037f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@wang1212

Copy link
Copy Markdown
Member

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves performance by avoiding redundant dirtying of parent elements. The change terminates the upward traversal in dirtyToRoot if a parent is already marked as dirty. A potential correctness issue was identified where the loop might terminate prematurely, leading to rendering artifacts. The suggested solution involves refining the loop condition to ensure all necessary dirty flags are set.

Comment thread packages/g-lite/src/services/SceneGraphService.ts Outdated
Alexzjt and others added 2 commits July 18, 2025 14:52
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@wang1212
wang1212 merged commit 433cc43 into master Jul 21, 2025
4 checks passed
@wang1212
wang1212 deleted the perf/dirty branch July 21, 2025 11:09
wang1212 added a commit that referenced this pull request Jul 30, 2025
* fix: prevent NaN in transform calculations when scale is 0 (#1971)

* fix: prevent NaN in transform calculations when scale is 0

- Add MIN_SCALE constant to avoid zero scaling
- Update scale transform functions to enforce minimum scale value
- Add test case for scale(0) transform
- Add demo example with scale(0) transform

* chore: add changeset

* refactor: extract scale clamping logic into reusable function

- Add clampScale helper function to avoid code duplication
- Replace repeated Math.max(item, MIN_SCALE) calls with clampScale
- Maintain same behavior while improving code maintainability

* chore: add changeset

* perf: use charWidthCache to improve performance by 1.5% (#1978)

* perf: 避免重复dirty父级元素提升2%性能

* perf: accept gemini review

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* refactor: 修复eslint

* perf: use charWidthCache to improve performance by 1.5%

* refactor: 修复评审意见

* refactor: 修复评审意见

* refactor: 使用LRU

* refactor: 使用LRU

* chore: add changeset

---------

Co-authored-by: huiyu.zjt <huiyu.zjt@antgroup.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: wang1212 <mrwang1212@126.com>

* revert: fix element attribute update exception #1968

* chore(release): bump version (#1977)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: huiyu.zjt <Alexzjt@users.noreply.github.com>
Co-authored-by: huiyu.zjt <huiyu.zjt@antgroup.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants