-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
DocumentSharedObjectPool prevents sharing of ElementData in case of hash collision #11681
DocumentSharedObjectPool prevents sharing of ElementData in case of hash collision #11681
Conversation
EWS run on previous version of this PR (hash 5dad145) |
return equalAttributes(reinterpret_cast<const uint8_t*>(attributes.data()), reinterpret_cast<const uint8_t*>(elementData.m_attributeArray), attributes.size() * sizeof(Attribute)); | ||
} | ||
struct DocumentSharedObjectPool::ShareableElementDataHash { | ||
static unsigned hash(const RefPtr<ShareableElementData>& o) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe data
instead of o
.
struct DocumentSharedObjectPool::ShareableElementDataHash { | ||
static unsigned hash(const RefPtr<ShareableElementData>& o) | ||
{ | ||
ASSERT_WITH_MESSAGE(o.get(), "attempt to use null RefPtr in HashTable"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you omit the get()
here? Also, I am pretty sure we support Ref
, not just RefPtr
, as a hash table key. Seems like thatβs called for here.
5dad145
to
725562a
Compare
EWS run on previous version of this PR (hash 725562a)
|
|
||
// FIXME: This prevents sharing when there's a hash collision. | ||
if (cachedData && !hasSameAttributes(attributes, *cachedData)) | ||
return m_shareableElementDataCache.ensure<AttributeSpanTranslator>(attributes, [attributes] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the translator already lazily creates the ShareableElementData
, couldnβt we just use add
instead of ensure
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I believe you're right. I'll update the patch.
725562a
to
d0baa49
Compare
EWS run on current version of this PR (hash d0baa49)
|
d0baa49
to
4bd9361
Compare
β¦ash collision https://bugs.webkit.org/show_bug.cgi?id=254114 Reviewed by Darin Adler. Use a HashSet of RefPtr<ShareableElementData> for the cache, with proper traits and hashing so that it does what we expect. This means we can let the HashSet implementation deal with hash collision and we can still share ElementData in the event of such collision. The previous code was using a HashMap whose key was the hash and thus couldn't deal with hash collision and would just not share in this case. This is performance neutral on Speedometer on both iPhone and Mac. * Source/WebCore/dom/DocumentSharedObjectPool.cpp: (WebCore::DocumentSharedObjectPool::ShareableElementDataHash::hash): (WebCore::DocumentSharedObjectPool::ShareableElementDataHash::equal): (WebCore::AttributeSpanTranslator::hash): (WebCore::AttributeSpanTranslator::equal): (WebCore::AttributeSpanTranslator::translate): (WebCore::DocumentSharedObjectPool::cachedShareableElementDataWithAttributes): (WebCore::hasSameAttributes): Deleted. * Source/WebCore/dom/DocumentSharedObjectPool.h: Canonical link: https://commits.webkit.org/261893@main
4bd9361
to
89317dd
Compare
Committed 261893@main (89317dd): https://commits.webkit.org/261893@main Reviewed commits have been landed. Closing PR #11681 and removing active labels. |
89317dd
4bd9361