Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e25d72b12cd9aea37de3dd55b87620b9c33ed13c
      
https://github.com/WebKit/WebKit/commit/e25d72b12cd9aea37de3dd55b87620b9c33ed13c
  Author: Nathan Solomon <[email protected]>
  Date:   2026-02-16 (Mon, 16 Feb 2026)

  Changed paths:
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/DocumentSharedObjectPool.cpp
    M Source/WebCore/dom/DocumentSharedObjectPool.h

  Log Message:
  -----------
  Reserve capacity for DocumentSharedObjectPool to improve perf of 
parserSetAttributes
https://bugs.webkit.org/show_bug.cgi?id=306548
rdar://169193738

Reviewed by Ryosuke Niwa.

We spend ~12% of time in 
WebCore::DocumentSharedObjectPool::cachedShareableElementDataWithAttributes
during parserSetAttributes which adds attributes to a HashSet<Ref, 
ShareableElementDataHash>.
After a closer look at the disassembly of 
cachedShareableElementDataWithAttributes(), we spend ~38%
of the time of this function doing quadratic probing.

Track peak element count (rounded up to nearest power of 2) per 
RegistrableDomain.
On subsequent visits to the same domain, reserve the set's capacity upfront with
its previously known peak count.

After reserving initial capacity, profiling shows that
DocumentSharedObjectPool::cachedShareableElementDataWithAttributes now shows
fewer quadratic probing operations.

This also reduces hash set resize events that were occurring.

This shows a small perf improvement.

* Source/WebCore/dom/Document.cpp:
(WebCore::Document::setParsing):
* Source/WebCore/dom/DocumentSharedObjectPool.cpp:
(WebCore::peakSizeInPast):
(WebCore::DocumentSharedObjectPool::DocumentSharedObjectPool):
(WebCore::DocumentSharedObjectPool::~DocumentSharedObjectPool):
* Source/WebCore/dom/DocumentSharedObjectPool.h:

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to