Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: addbd50745f9aa2f05f976bfbf0dab7634cc7c4a
https://github.com/WebKit/WebKit/commit/addbd50745f9aa2f05f976bfbf0dab7634cc7c4a
Author: Chris Dumez <[email protected]>
Date: 2026-01-06 (Tue, 06 Jan 2026)
Changed paths:
M Source/WTF/wtf/text/StringCommon.h
Log Message:
-----------
Micro-optimize `WTF::equal(const char16_t* a, std::span<const char16_t> b)`
https://bugs.webkit.org/show_bug.cgi?id=304921
Reviewed by Yusuke Suzuki.
Micro-optimize `WTF::equal(const char16_t* a, std::span<const char16_t> b)`
as recommended by Claude AI:
Micro benchmark results:
Length Bytes Original (ns) Optimized (ns) Speedup Improvement
Status
----------------------------------------------------------------------------------------
2 4 1.82 1.58 1.153x
+13.3% OK
3 6 1.59 1.58 1.003x
+0.3% OK
4 8 1.58 1.59 0.997x
-0.3% OK
5 10 1.58 1.56 1.010x
+1.0% OK
6 12 1.56 1.68 0.930x
-7.5% OK
7 14 1.59 1.57 1.012x
+1.2% OK
8 16 1.57 1.56 1.005x
+0.5% OK
9 18 1.58 1.60 0.986x
-1.4% OK
10 20 1.59 1.59 0.998x
-0.2% OK
12 24 1.59 1.59 1.000x
+0.0% OK
14 28 1.60 1.60 1.003x
+0.3% OK
16 32 1.59 1.61 0.989x
-1.1% OK
17 34 1.71 1.68 1.018x
+1.8% OK
20 40 1.71 1.66 1.031x
+3.0% OK
24 48 1.75 1.68 1.043x
+4.1% OK
28 56 1.74 1.66 1.053x
+5.0% OK
32 64 1.85 1.67 1.105x
+9.5% OK
33 66 1.84 1.74 1.056x
+5.3% OK
40 80 2.23 1.74 1.285x
+22.2% OK
48 96 2.46 1.99 1.237x
+19.1% OK
64 128 3.01 2.37 1.270x
+21.3% OK
80 160 3.55 2.96 1.200x
+16.6% OK
100 200 4.16 3.81 1.094x
+8.6% OK
128 256 5.47 4.70 1.163x
+14.0% OK
256 512 10.28 9.10 1.130x
+11.5% OK
512 1024 19.34 16.76 1.154x
+13.3% OK
1024 2048 49.12 40.56 1.211x
+17.4% OK
2048 4096 89.04 79.29 1.123x
+11.0% OK
----------------------------------------------------------------------------------------
Average speedup: 1.135x
Total improvement: 11.9%
Key Findings
1. Small Strings (2-16 elements, 4-32 bytes): Minimal Impact
Noise-level differences (±1-2%)
Already well-optimized, dominated by branch prediction
2. Case 5 - NEW OPTIMIZATION (17-32 elements, 34-64 bytes): Good Gains
32 elements: +9.5% - the new 4-SIMD-load path is working!
24 elements: +4.1%
28 elements: +5.0%
Progressive improvement as length increases toward 32
3. Default Case (33+ elements, 66+ bytes): Strong Gains
Best improvements at 40-64 elements: +19-22% 🔥
40 elements: +22.2% - exceptional!
48 elements: +19.1%
64 elements: +21.3%
The fixed loop logic (starting at i=16 instead of i=length%8) really shines here
4. Large Strings (100+ elements): Solid 10-15% Gains
Consistent improvements throughout
1024 elements: +17.4% - very good for such a large string
* Source/WTF/wtf/text/StringCommon.h:
(WTF::equal):
Canonical link: https://commits.webkit.org/305182@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications