Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of many shadow trees with unique style triggers significant CPU usage and a rise in process size #18889

Merged

Conversation

anttijk
Copy link
Contributor

@anttijk anttijk commented Oct 10, 2023

b3c5d42

Use of many shadow trees with unique style triggers significant CPU usage and a rise in process size
https://bugs.webkit.org/show_bug.cgi?id=260925
rdar://114731415

Reviewed by Alan Baradlay.

Style resolver sharing cache in Style::Scope has unlimited size and the test case keeps adding more items
there. Low memory handler clears the cache causing memory use to eventually drop.

* Source/WebCore/dom/InlineStyleSheetOwner.cpp:
(WebCore::InlineStyleSheetOwner::createSheet):

Increase the size of the inline stylesheet sharing cache  (50 -> 256 items). Content that uses many unique
shadow tree style (like this test) could overrun this smallish cache easily rendering it ineffective.

Style resolver sharing in Style::Scope depends on inline stylesheet getting shared so this also made
that cache work poorly.

* Source/WebCore/style/StyleScope.cpp:
(WebCore::Style::Scope::createOrFindSharedShadowTreeResolver):

Add a limit to the resolver sharing cache size.

Canonical link: https://commits.webkit.org/269142@main

fbb033f

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style   πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings   πŸ›  ios-sim βœ… πŸ›  mac-AS-debug   πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ›  gtk
  πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 βœ… πŸ§ͺ gtk-wk2
  πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  tv-sim
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch
βœ… πŸ›  watch-sim

@anttijk anttijk self-assigned this Oct 10, 2023
@anttijk anttijk added the CSS Cascading Style Sheets implementation label Oct 10, 2023
@anttijk anttijk force-pushed the style-resolver-sharing-limit branch from 2cb9ccf to 6d8dc58 Compare October 10, 2023 10:31
@anttijk anttijk force-pushed the style-resolver-sharing-limit branch from 6d8dc58 to 14d1276 Compare October 10, 2023 11:47
@anttijk anttijk force-pushed the style-resolver-sharing-limit branch from 14d1276 to fbb033f Compare October 10, 2023 11:51
@anttijk anttijk added the merge-queue Applied to send a pull request to merge-queue label Oct 10, 2023
…sage and a rise in process size

https://bugs.webkit.org/show_bug.cgi?id=260925
rdar://114731415

Reviewed by Alan Baradlay.

Style resolver sharing cache in Style::Scope has unlimited size and the test case keeps adding more items
there. Low memory handler clears the cache causing memory use to eventually drop.

* Source/WebCore/dom/InlineStyleSheetOwner.cpp:
(WebCore::InlineStyleSheetOwner::createSheet):

Increase the size of the inline stylesheet sharing cache  (50 -> 256 items). Content that uses many unique
shadow tree style (like this test) could overrun this smallish cache easily rendering it ineffective.

Style resolver sharing in Style::Scope depends on inline stylesheet getting shared so this also made
that cache work poorly.

* Source/WebCore/style/StyleScope.cpp:
(WebCore::Style::Scope::createOrFindSharedShadowTreeResolver):

Add a limit to the resolver sharing cache size.

Canonical link: https://commits.webkit.org/269142@main
@webkit-commit-queue
Copy link
Collaborator

Committed 269142@main (b3c5d42): https://commits.webkit.org/269142@main

Reviewed commits have been landed. Closing PR #18889 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit b3c5d42 into WebKit:main Oct 10, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Oct 10, 2023
@anttijk anttijk deleted the style-resolver-sharing-limit branch October 18, 2023 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Cascading Style Sheets implementation
Projects
None yet
4 participants