RESOLVED FIXED 194021
Eliminate unnecessary String temporaries by using StringConcatenateNumbers
https://bugs.webkit.org/show_bug.cgi?id=194021
Summary Eliminate unnecessary String temporaries by using StringConcatenateNumbers
Darin Adler
Reported 2019-01-30 08:17:41 PST
Eliminate unnecessary String temporaries by using StringConcatenateNumbers
Attachments
Patch (73.78 KB, patch)
2019-01-30 08:37 PST, Darin Adler
no flags
Patch (74.14 KB, patch)
2019-01-30 09:03 PST, Darin Adler
no flags
Patch (74.25 KB, patch)
2019-01-30 09:05 PST, Darin Adler
no flags
Patch (74.92 KB, patch)
2019-01-30 09:17 PST, Darin Adler
no flags
Archive of layout-test-results from ews102 for mac-highsierra (2.50 MB, application/zip)
2019-01-30 10:29 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews106 for mac-highsierra-wk2 (2.62 MB, application/zip)
2019-01-30 10:29 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews121 for ios-simulator-wk2 (525.16 KB, application/zip)
2019-01-30 10:47 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews114 for mac-highsierra (2.15 MB, application/zip)
2019-01-30 11:08 PST, EWS Watchlist
no flags
Patch (75.63 KB, patch)
2019-02-01 19:19 PST, Darin Adler
no flags
Patch (75.88 KB, patch)
2019-02-01 19:42 PST, Darin Adler
no flags
Patch (75.87 KB, patch)
2019-02-01 20:14 PST, Darin Adler
no flags
Archive of layout-test-results from ews101 for mac-highsierra (4.59 MB, application/zip)
2019-02-01 21:26 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews104 for mac-highsierra-wk2 (4.73 MB, application/zip)
2019-02-01 21:34 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews114 for mac-highsierra (4.19 MB, application/zip)
2019-02-01 22:07 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews206 for win-future (14.97 MB, application/zip)
2019-02-01 22:33 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews123 for ios-simulator-wk2 (732.89 KB, application/zip)
2019-02-01 23:22 PST, EWS Watchlist
no flags
Patch (83.51 KB, patch)
2019-02-03 09:35 PST, Darin Adler
no flags
Patch (98.87 KB, patch)
2019-02-05 21:26 PST, Darin Adler
no flags
Archive of layout-test-results from ews124 for ios-simulator-wk2 (2.49 MB, application/zip)
2019-02-05 23:15 PST, EWS Watchlist
no flags
Patch (98.90 KB, patch)
2019-02-08 18:55 PST, Darin Adler
no flags
Patch (99.07 KB, patch)
2019-02-09 08:13 PST, Darin Adler
ggaren: review+
ews-watchlist: commit-queue-
Archive of layout-test-results from ews121 for ios-simulator-wk2 (2.49 MB, application/zip)
2019-02-09 10:22 PST, EWS Watchlist
no flags
Darin Adler
Comment 1 2019-01-30 08:37:44 PST Comment hidden (obsolete)
Darin Adler
Comment 2 2019-01-30 09:03:07 PST Comment hidden (obsolete)
Darin Adler
Comment 3 2019-01-30 09:05:21 PST Comment hidden (obsolete)
Darin Adler
Comment 4 2019-01-30 09:17:10 PST Comment hidden (obsolete)
EWS Watchlist
Comment 5 2019-01-30 10:29:29 PST Comment hidden (obsolete)
EWS Watchlist
Comment 6 2019-01-30 10:29:31 PST Comment hidden (obsolete)
EWS Watchlist
Comment 7 2019-01-30 10:29:57 PST Comment hidden (obsolete)
EWS Watchlist
Comment 8 2019-01-30 10:29:59 PST Comment hidden (obsolete)
EWS Watchlist
Comment 9 2019-01-30 10:47:24 PST Comment hidden (obsolete)
EWS Watchlist
Comment 10 2019-01-30 10:47:25 PST Comment hidden (obsolete)
EWS Watchlist
Comment 11 2019-01-30 11:08:04 PST Comment hidden (obsolete)
EWS Watchlist
Comment 12 2019-01-30 11:08:06 PST Comment hidden (obsolete)
Darin Adler
Comment 13 2019-02-01 19:19:41 PST Comment hidden (obsolete)
Darin Adler
Comment 14 2019-02-01 19:42:04 PST Comment hidden (obsolete)
Darin Adler
Comment 15 2019-02-01 20:14:56 PST Comment hidden (obsolete)
EWS Watchlist
Comment 16 2019-02-01 21:26:42 PST Comment hidden (obsolete)
EWS Watchlist
Comment 17 2019-02-01 21:26:43 PST Comment hidden (obsolete)
EWS Watchlist
Comment 18 2019-02-01 21:34:18 PST Comment hidden (obsolete)
EWS Watchlist
Comment 19 2019-02-01 21:34:20 PST Comment hidden (obsolete)
EWS Watchlist
Comment 20 2019-02-01 22:07:08 PST Comment hidden (obsolete)
EWS Watchlist
Comment 21 2019-02-01 22:07:10 PST Comment hidden (obsolete)
EWS Watchlist
Comment 22 2019-02-01 22:33:28 PST Comment hidden (obsolete)
EWS Watchlist
Comment 23 2019-02-01 22:33:41 PST Comment hidden (obsolete)
EWS Watchlist
Comment 24 2019-02-01 23:22:12 PST Comment hidden (obsolete)
EWS Watchlist
Comment 25 2019-02-01 23:22:14 PST Comment hidden (obsolete)
Darin Adler
Comment 26 2019-02-03 09:35:13 PST Comment hidden (obsolete)
Darin Adler
Comment 27 2019-02-05 21:26:32 PST Comment hidden (obsolete)
EWS Watchlist
Comment 28 2019-02-05 23:15:49 PST Comment hidden (obsolete)
EWS Watchlist
Comment 29 2019-02-05 23:15:50 PST Comment hidden (obsolete)
Darin Adler
Comment 30 2019-02-08 18:55:12 PST Comment hidden (obsolete)
Darin Adler
Comment 31 2019-02-09 08:13:18 PST
Darin Adler
Comment 32 2019-02-09 10:10:07 PST
Comment on attachment 361606 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=361606&action=review I think this is ready for review now. Basically all tests passing everything compiling on all platforms. One small nit right at the moment: Not sure why there are tests failing on ios-sim buildbot (still running, so maybe it's a glitch); did not see those tests fail with the almost identical previous version of the same patch (was all green). I did not touch the serialization done by the function named makeString in Wasm nor call sites like JSC::BuiltinNames::getPublicName; there are some places in both categories that allocate unnecessary String temporaries and that could be using StringView or StringConcatenateNumbers instead, but things got a little too complicated for me to understand how to make safe fixes there without deeper thinking and more care. I think we should probably rename the makeString function in WasmOps.h to avoid confusion with the makeString in WTF since they are different and it’s easy to be confused about which one a given call site is calling. Note however, that sometimes what looks like an unnecessary String temporary is just reference counting churn, making a String since makeString doesn’t work with StringImpl directly. That’s much less expensive than allocating/destroying a StringImpl, which is the bigger thing we are fixing in most cases here in this patch. The only significant challenge in getting this patch correct was that for floating point numbers, the makeString default is ECMAScript-style shortest form, and the String::number and StringBuilder::appendNumber default is 6 digits, fixed precision, strip trailing zeroes. For many cases, the two approaches are basically equivalent and it’s nice to move to the shortest form as a more elegant solution to the same problem, but a big exception is when it’s a float rather than a double, because we don’t currently have a float shortest form implementation. So for those cases, I had to be careful to preserve the use of fixed precision. Would be nice to fix that eventually so we can reduce the unnecessary use of fixed precision, since shortest is almost always better. In fact, if we fixed that I would also want to change the String::number and StringBuilder::appendNumber defaults as well. So, for now, any place where String::number is replaced by the use of makeString, if it’s an integer or if it’s a double and shortest form is equivalent/OK we can do it in the simplest form, but if it’s a float then we almost always have to use FormattedNumber::fixedPrecision to preserve behavior for now. > Source/JavaScriptCore/runtime/NumberPrototype.cpp:468 > - NumberToStringBuffer buffer; > - return JSValue::encode(jsString(exec, String(numberToFixedWidthString(x, decimalPlaces, buffer)))); > + return JSValue::encode(jsString(exec, String::numberToStringFixedWidth(x, decimalPlaces))); This does add one function call: I’ll need to double check to be sure this doesn’t slow things down, but it’s unlikely. > Source/JavaScriptCore/runtime/NumberPrototype.cpp:504 > - NumberToStringBuffer buffer; > - return JSValue::encode(jsString(exec, String(numberToFixedPrecisionString(x, significantFigures, buffer)))); > + return JSValue::encode(jsString(exec, String::number(x, significantFigures, KeepTrailingZeros))); Ditto.
EWS Watchlist
Comment 33 2019-02-09 10:22:08 PST
Comment on attachment 361606 [details] Patch Attachment 361606 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: https://webkit-queues.webkit.org/results/11092013 New failing tests: imported/w3c/web-platform-tests/webrtc/simplecall-no-ssrcs.https.html
EWS Watchlist
Comment 34 2019-02-09 10:22:10 PST
Created attachment 361609 [details] Archive of layout-test-results from ews121 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews121 Port: ios-simulator-wk2 Platform: Mac OS X 10.13.6
Darin Adler
Comment 35 2019-02-09 10:34:51 PST
I can’t see any way these failures would be due to the patch.
Darin Adler
Comment 36 2019-02-09 10:35:40 PST
The failure is a crash inside WebCore::PixelBufferConformerCV::convert.
Darin Adler
Comment 37 2019-02-09 12:05:41 PST
I’d love to land this now. Looking for a reviewer.
Geoffrey Garen
Comment 38 2019-02-09 12:52:43 PST
Comment on attachment 361606 [details] Patch r=me
Darin Adler
Comment 39 2019-02-09 13:01:41 PST
Radar WebKit Bug Importer
Comment 40 2019-02-09 13:04:41 PST
Note You need to log in before you can comment on or make changes to this bug.