RESOLVED FIXED 249873
AX: Pre-size AXIsolatedObject::m_propertyMap to avoid unnecessary HashTable reallocations
https://bugs.webkit.org/show_bug.cgi?id=249873
Summary AX: Pre-size AXIsolatedObject::m_propertyMap to avoid unnecessary HashTable r...
Tyler Wilcock
Reported 2022-12-24 11:37:49 PST
AX: Pre-size AXIsolatedObject::m_propertyMap to avoid unnecessary HashTable reallocations
Attachments
Patch (4.62 KB, patch)
2022-12-24 11:42 PST, Tyler Wilcock
no flags
Radar WebKit Bug Importer
Comment 1 2022-12-24 11:37:59 PST
Tyler Wilcock
Comment 2 2022-12-24 11:42:38 PST
chris fleizach
Comment 3 2022-12-24 11:48:50 PST
Comment on attachment 464196 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=464196&action=review > Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp:57 > + m_propertyMap.reserveInitialCapacity(126); Is there a way to calculate this number less manually
Tyler Wilcock
Comment 4 2022-12-24 11:56:27 PST
(In reply to chris fleizach from comment #3) > Comment on attachment 464196 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=464196&action=review > > > Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp:57 > > + m_propertyMap.reserveInitialCapacity(126); > > Is there a way to calculate this number less manually I don't think so. We could do: m_propertyMap.reserveInitialCapacity(static_cast<unsigned>(AXPropertyName::VisibleRows)); Where AXPropertyName::VisibleRows is the last member of the AXPropertyName enum class. But that would assume that every object has every property, which definitely isn't true, and would cause us to over-allocate the hashmap for every object.
Tyler Wilcock
Comment 5 2022-12-24 12:01:56 PST
> > Is there a way to calculate this number less manually > I don't think so. We could do: > > m_propertyMap.reserveInitialCapacity(static_cast<unsigned>(AXPropertyName:: > VisibleRows)); > > Where AXPropertyName::VisibleRows is the last member of the AXPropertyName > enum class. But that would assume that every object has every property, > which definitely isn't true, and would cause us to over-allocate the hashmap > for every object. Though we could probably do it if we had some structure that defined the properties for each type of object (i.e. something like WebAccessibilityObjectWrapperMac::accessibilityAttributeNames does), rather than the ad-hoc initialization we do now in AXIsolatedObject::initializeProperties. But sizing the map based on such a structure would be invalidated by sparse property storage, too, so probably not worth the work to do.
EWS
Comment 6 2022-12-24 18:52:52 PST
Committed 258328@main (98a28389be81): <https://commits.webkit.org/258328@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 464196 [details].
Note You need to log in before you can comment on or make changes to this bug.