Bug 225223 - Optimize SortedArrayMap by using linear search for small arrays
Summary: Optimize SortedArrayMap by using linear search for small arrays
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Darin Adler
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-04-29 19:17 PDT by Darin Adler
Modified: 2021-04-30 09:03 PDT (History)
7 users (show)

See Also:


Attachments
Patch (8.85 KB, patch)
2021-04-29 19:21 PDT, Darin Adler
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 2021-04-29 19:17:55 PDT
Optimize SortedArrayMap by using linear search for small arrays
Comment 1 Darin Adler 2021-04-29 19:21:09 PDT
Created attachment 427396 [details]
Patch
Comment 2 Yusuke Suzuki 2021-04-29 22:02:01 PDT
Comment on attachment 427396 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=427396&action=review

r=me

> Source/WTF/wtf/SortedArrayMap.h:145
> +    if (std::size(m_array) < binarySearchThreshold) {

How about making it `if constexpr` to ensure that this dispatching is done at compile time.

> Source/WTF/wtf/SortedArrayMap.h:177
> +    if (std::size(m_array) < binarySearchThreshold)

Ditto.
Comment 3 Darin Adler 2021-04-30 08:57:57 PDT
Comment on attachment 427396 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=427396&action=review

>> Source/WTF/wtf/SortedArrayMap.h:145
>> +    if (std::size(m_array) < binarySearchThreshold) {
> 
> How about making it `if constexpr` to ensure that this dispatching is done at compile time.

Tried if constexpr first. The compiler gave an error saying that I could not use "this" in it, so I would have had to find some way to get the size from the type rather than from m_array. Decided to leave it non-constexpr; still gets constant-folded.
Comment 4 Darin Adler 2021-04-30 08:58:49 PDT
Comment on attachment 427396 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=427396&action=review

>>> Source/WTF/wtf/SortedArrayMap.h:145
>>> +    if (std::size(m_array) < binarySearchThreshold) {
>> 
>> How about making it `if constexpr` to ensure that this dispatching is done at compile time.
> 
> Tried if constexpr first. The compiler gave an error saying that I could not use "this" in it, so I would have had to find some way to get the size from the type rather than from m_array. Decided to leave it non-constexpr; still gets constant-folded.

If you help me find a clean simple way for me to move to if constexpr without making the code ugly, would be happy to come back and do that later.
Comment 5 EWS 2021-04-30 09:02:59 PDT
Committed r276840 (237191@main): <https://commits.webkit.org/237191@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 427396 [details].
Comment 6 Radar WebKit Bug Importer 2021-04-30 09:03:27 PDT
<rdar://problem/77385092>