RESOLVED FIXED 30436
fast/css/large-list-of-rules-crash.html concatenates strings in an inefficient way
https://bugs.webkit.org/show_bug.cgi?id=30436
Summary fast/css/large-list-of-rules-crash.html concatenates strings in an inefficien...
Yuta Kitamura
Reported 2009-10-16 02:33:32 PDT
LayoutTest/fast/css/large-list-of-rules-crash.html contains JavaScript code that repeatedly concatenates strings in an inefficient way. Concatenation of strings should be done using Array.join method.
Attachments
Fix inefficient string concatenation. (2.07 KB, patch)
2009-10-16 02:38 PDT, Yuta Kitamura
no flags
Yuta Kitamura
Comment 1 2009-10-16 02:38:49 PDT
Created attachment 41279 [details] Fix inefficient string concatenation.
Mark Rowe (bdash)
Comment 2 2009-10-16 03:11:30 PDT
Can you please explain why this change is necessary? In my measurements with TOT WebKit there’s approximately 10ms of difference between the two approaches, accounting for less than 2% of the execution time of this test.
Yuta Kitamura
Comment 3 2009-10-17 22:45:11 PDT
(In reply to comment #2) > Can you please explain why this change is necessary? In my measurements with > TOT WebKit there’s approximately 10ms of difference between the two approaches, > accounting for less than 2% of the execution time of this test. Yes, as for JavaScriptCore, only small improvement can be observed. However, currently debug version of V8 is hitting this problem and consuming test cycles. I admit the argument above is weak..., but I believe there is no need to leave an inefficient test as is.
Mark Rowe (bdash)
Comment 4 2009-10-17 22:46:34 PDT
It’d be stronger if you took a few seconds to provide data to support your claim that it is inefficient.
Yuta Kitamura
Comment 5 2009-10-17 22:57:45 PDT
(In reply to comment #4) > It’d be stronger if you took a few seconds to provide data to support your > claim that it is inefficient. Original code look like this: var s = ""; for (i = 0 ; i < 200000 ; i++) { s += "a {}\n"; } This code produces potentially (especially for debug binary) allocation of 200000 string objects with length of 5, 10, 15, ..., 5*200000. The fixed version does not require the intermediate string objects. I believe using Array.join is the common pattern to avoid unneeded allocation.
Mark Rowe (bdash)
Comment 6 2009-10-17 23:02:46 PDT
You’ve just restated what the patch does. I’m interested in specifics about how much of an improvement this change is.
Yuta Kitamura
Comment 7 2009-10-17 23:13:29 PDT
(In reply to comment #6) > You’ve just restated what the patch does. I’m interested in specifics about > how much of an improvement this change is. From 30sec to 3sec, as for V8 debug.
Mark Rowe (bdash)
Comment 8 2009-10-17 23:15:14 PDT
Thanks!
WebKit Commit Bot
Comment 9 2009-10-17 23:27:24 PDT
Comment on attachment 41279 [details] Fix inefficient string concatenation. Clearing flags on attachment: 41279 Committed r49748: <http://trac.webkit.org/changeset/49748>
WebKit Commit Bot
Comment 10 2009-10-17 23:27:27 PDT
All reviewed patches have been landed. Closing bug.
Yuta Kitamura
Comment 11 2009-10-18 00:26:05 PDT
Thanks!
Note You need to log in before you can comment on or make changes to this bug.