RESOLVED FIXED 83968
Add a version of StringImpl::find() without offset
https://bugs.webkit.org/show_bug.cgi?id=83968
Summary Add a version of StringImpl::find() without offset
Benjamin Poulain
Reported 2012-04-13 19:21:57 PDT
Since the function is not inline, the offset forces a bunch of extra operations.
Attachments
Patch (13.50 KB, patch)
2012-04-13 20:18 PDT, Benjamin Poulain
no flags
Archive of layout-test-results from ec2-cr-linux-04 (6.40 MB, application/zip)
2012-04-14 00:33 PDT, WebKit Review Bot
no flags
Archive of layout-test-results from ec2-cr-linux-02 (6.58 MB, application/zip)
2012-04-14 01:34 PDT, WebKit Review Bot
no flags
Patch for landing (12.86 KB, patch)
2012-04-24 17:08 PDT, Benjamin Poulain
no flags
Patch (14.71 KB, patch)
2012-04-24 17:50 PDT, Benjamin Poulain
no flags
Archive of layout-test-results from ec2-cr-linux-03 (6.09 MB, application/zip)
2012-04-25 05:13 PDT, WebKit Review Bot
no flags
Patch (15.57 KB, patch)
2012-04-25 15:48 PDT, Benjamin Poulain
no flags
Benjamin Poulain
Comment 1 2012-04-13 20:18:20 PDT
Benjamin Poulain
Comment 2 2012-04-13 20:19:31 PDT
This is on top of https://bugs.webkit.org/show_bug.cgi?id=83961 You can ignore the bots.
Build Bot
Comment 3 2012-04-13 20:50:12 PDT
WebKit Review Bot
Comment 4 2012-04-14 00:33:21 PDT
Comment on attachment 137194 [details] Patch Attachment 137194 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/12406194 New failing tests: fast/xpath/substring-after.html fast/xpath/4XPath/Core/test_core_functions.html
WebKit Review Bot
Comment 5 2012-04-14 00:33:27 PDT
Created attachment 137199 [details] Archive of layout-test-results from ec2-cr-linux-04 The attached test failures were seen while running run-webkit-tests on the chromium-ews. Bot: ec2-cr-linux-04 Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'> Platform: Linux-2.6.35-28-virtual-x86_64-with-Ubuntu-10.10-maverick
WebKit Review Bot
Comment 6 2012-04-14 01:34:04 PDT
Comment on attachment 137194 [details] Patch Attachment 137194 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/12408122 New failing tests: fast/xpath/substring-after.html fast/xpath/4XPath/Core/test_core_functions.html
WebKit Review Bot
Comment 7 2012-04-14 01:34:10 PDT
Created attachment 137200 [details] Archive of layout-test-results from ec2-cr-linux-02 The attached test failures were seen while running run-webkit-tests on the chromium-ews. Bot: ec2-cr-linux-02 Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'> Platform: Linux-2.6.35-28-virtual-x86_64-with-Ubuntu-10.10-maverick
Sam Weinig
Comment 8 2012-04-15 16:13:27 PDT
Comment on attachment 137194 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=137194&action=review > Source/JavaScriptCore/ChangeLog:11 > + This gives a 12% gains for strings of distribution of strings between 30 and 100 characters. I don't completely understand this sentence. > Source/WTF/ChangeLog:11 > + By not havig the index, we can skip a couple of branches and a few instructions. This gives Typo: havig -> having. > Source/WTF/ChangeLog:14 > + The case of empty string is moved bellow (matchLength == 1) since it is a less common operation. Typo: bellow -> below. How did you determine that finding on the empty string is less common? > Source/WTF/wtf/text/StringImpl.cpp:901 > + // Check for null or empty string to match against > + if (UNLIKELY(!matchString)) > + return notFound; I don't think this checks for empty strings.
Benjamin Poulain
Comment 9 2012-04-15 19:09:34 PDT
Thanks for the review. Sorry I butchered that ChangeLog. > > Source/WTF/ChangeLog:14 > > + The case of empty string is moved bellow (matchLength == 1) since it is a less common operation. > > How did you determine that finding on the empty string is less common? It is actually just an assumption. The case of length==1 is pretty common from JavaScript.
Benjamin Poulain
Comment 10 2012-04-24 17:08:48 PDT
Created attachment 138695 [details] Patch for landing
Darin Adler
Comment 11 2012-04-24 17:31:48 PDT
Comment on attachment 138695 [details] Patch for landing View in context: https://bugs.webkit.org/attachment.cgi?id=138695&action=review > Source/JavaScriptCore/runtime/StringPrototype.cpp:781 > + if (pos) > + result = s.find(u2, pos); > + else > + result = s.find(u2); I don’t get how this could be an improvement. Can’t the normal find just optimize just as well for the case where pos is 0 as an if statement can?
Benjamin Poulain
Comment 12 2012-04-24 17:50:44 PDT
Benjamin Poulain
Comment 13 2012-04-24 17:58:28 PDT
> > Source/JavaScriptCore/runtime/StringPrototype.cpp:781 > > + if (pos) > > + result = s.find(u2, pos); > > + else > > + result = s.find(u2); > > I don’t get how this could be an improvement. Can’t the normal find just optimize just as well for the case where pos is 0 as an if statement can? Yep, I was divided on that one... It was showing improvement on JavaScript because the source strings are big enough on average. I did not want to risk slowing down something else with the extra branch and function call. Since you also think that does not look great, I removed that from the latest version. I can change this later if needed.
Benjamin Poulain
Comment 14 2012-04-24 18:05:54 PDT
Comment on attachment 138704 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=138704&action=review > Source/JavaScriptCore/runtime/StringPrototype.cpp:764 > if (a1.isUndefined()) > - pos = 0; > - else if (a1.isUInt32()) > - pos = min<uint32_t>(a1.asUInt32(), len); > + result = s.find(u2); This is the best case for this patch, and it is also very common, so I am fine sticking with this.
Benjamin Poulain
Comment 15 2012-04-24 19:24:59 PDT
Finally solved the symbol issue. Sam, would you mind looking at the changes and confirm it is still ok to land: -removed the if(pos==0) following Darin comment -added the new symbol for WebKit2 Windows
WebKit Review Bot
Comment 16 2012-04-25 05:13:34 PDT
Comment on attachment 138704 [details] Patch Attachment 138704 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/12535242 New failing tests: fast/xpath/substring-after.html fast/xpath/4XPath/Core/test_core_functions.html
WebKit Review Bot
Comment 17 2012-04-25 05:13:41 PDT
Created attachment 138787 [details] Archive of layout-test-results from ec2-cr-linux-03 The attached test failures were seen while running run-webkit-tests on the chromium-ews. Bot: ec2-cr-linux-03 Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'> Platform: Linux-2.6.35-28-virtual-x86_64-with-Ubuntu-10.10-maverick
Benjamin Poulain
Comment 18 2012-04-25 15:48:19 PDT
Benjamin Poulain
Comment 19 2012-04-25 22:31:05 PDT
Csaba Osztrogonác
Comment 20 2012-04-25 22:34:56 PDT
Reopen, because http://trac.webkit.org/changeset/115290 broke the Qt Mac build. Bot unfortunately I can't paste build log, because build.webkit.org is died at the moment.
Csaba Osztrogonác
Comment 21 2012-04-25 22:37:49 PDT
build.webkit.org works again, so here is the build log: ../../../../Source/WebCore/bridge/qt/qt_runtime.cpp: In function ‘bool JSC::Bindings::isJSUint8ClampedArray(JSC::JSValue)’: ../../../../Source/WebCore/bridge/qt/qt_runtime.cpp:142: error: ‘JSUint8ClampedArray’ is not a class or namespace
Csaba Osztrogonác
Comment 22 2012-04-25 22:46:03 PDT
Sorry for blaming this patch, it is absolutely innocent. :)
Note You need to log in before you can comment on or make changes to this bug.