[webkit-changes] [WebKit/WebKit] 4d7698: Simplify amortized cleanup algorighm for weak hash...
Alex Christensen
noreply at github.com
Tue Aug 8 21:26:58 PDT 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 4d7698241f39bd3d19ba4cddad79118149a502ee
https://github.com/WebKit/WebKit/commit/4d7698241f39bd3d19ba4cddad79118149a502ee
Author: Alex Christensen <achristensen at apple.com>
Date: 2023-08-08 (Tue, 08 Aug 2023)
Changed paths:
M Source/WTF/wtf/ThreadSafeWeakHashSet.h
M Source/WTF/wtf/WeakHashMap.h
M Source/WTF/wtf/WeakHashSet.h
M Source/WTF/wtf/WeakListHashSet.h
M Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp
Log Message:
-----------
Simplify amortized cleanup algorighm for weak hash structures
https://bugs.webkit.org/show_bug.cgi?id=259847
rdar://113419306
Reviewed by Chris Dumez.
In 266594 at main Chris fixed an important bug where if you only add to a
ThreadSafeHashSet, you never hit the cleanup condition of the container.
Other containers had this same issue. This simplifies the algorithm used
to determine whether to clean up the container to just this:
1. Increase the operation count when an add/remove operation happens.
2. If the operation count has exceeded the threshold, clean up.
3. When cleaning up, set the threshold to 2 * the current size.
That is still amortized, doesn't have the issue Chris fixed, and is simpler
to reason about and easier to see what is going on.
* Source/WTF/wtf/ThreadSafeWeakHashSet.h:
* Source/WTF/wtf/WeakHashMap.h:
* Source/WTF/wtf/WeakHashSet.h:
* Source/WTF/wtf/WeakListHashSet.h:
Canonical link: https://commits.webkit.org/266713@main
More information about the webkit-changes
mailing list