Bug 211078

Summary: Improve performance of commonInclusiveAncestor for deeply nested nodes
Product: WebKit Reporter: Darin Adler <darin>
Component: DOMAssignee: Darin Adler <darin>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, esprehn+autocc, ews-watchlist, kangil.han, koivisto, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch
none
Patch koivisto: review+

Darin Adler
Reported 2020-04-27 08:22:32 PDT
Improve performance of commonInclusiveAncestor for deeply nested nodes
Attachments
Patch (2.14 KB, patch)
2020-04-27 08:24 PDT, Darin Adler
no flags
Patch (2.15 KB, patch)
2020-04-27 08:28 PDT, Darin Adler
no flags
Patch (2.16 KB, patch)
2020-04-27 08:39 PDT, Darin Adler
koivisto: review+
Darin Adler
Comment 1 2020-04-27 08:24:13 PDT Comment hidden (obsolete)
Darin Adler
Comment 2 2020-04-27 08:26:08 PDT Comment hidden (obsolete)
Darin Adler
Comment 3 2020-04-27 08:28:23 PDT Comment hidden (obsolete)
Darin Adler
Comment 4 2020-04-27 08:39:19 PDT
Antti Koivisto
Comment 5 2020-04-27 09:06:16 PDT
Comment on attachment 397686 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=397686&action=review findNearestCommonComposedAncestor has another implementation using a HashSet. Yours is probably better since it avoids allocation and hashing even if it requires more traversal. > Source/WebCore/dom/Node.cpp:2627 > + auto [depthA, depthB] = std::make_tuple(depth(a), depth(b)); > + auto [x, y, difference] = depthA > depthB Interesting use of temporary tuples.
Antti Koivisto
Comment 6 2020-04-27 09:08:24 PDT
If a==b is common it might be worth optimizing for it.
Darin Adler
Comment 7 2020-04-27 09:18:31 PDT
(In reply to Antti Koivisto from comment #6) > If a==b is common it might be worth optimizing for it. Maybe I should speculatively include that without even measuring?
Antti Koivisto
Comment 8 2020-04-27 09:31:14 PDT
Yeah, it is such a cheap test.
Darin Adler
Comment 9 2020-04-27 09:45:39 PDT
Tempting to also add a special case for when a and b both have the same parent. But for now I will not.
Darin Adler
Comment 10 2020-04-27 09:47:28 PDT
Radar WebKit Bug Importer
Comment 11 2020-04-27 09:48:15 PDT
Note You need to log in before you can comment on or make changes to this bug.