[Webkit-unassigned] [Bug 155551] Pathological performance on first execution of a function called with mismatched argument count

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Mar 16 12:56:36 PDT 2016


https://bugs.webkit.org/show_bug.cgi?id=155551

--- Comment #5 from Oliver Hunt <oliver at apple.com> ---
(In reply to comment #4)
> Here's the case that originally struct me as wrong:
> 
> function f(j) { for (var i = 0 ; i < 10000000; i++) j = (j ?  j * i : 1) ^
> (i & j); };
> 
> var start = new Date; f(); var end = new Date; print("2nd: " + (end - start)
> + "ms");
> var start = new Date; f(); var end = new Date; print("3rd: " + (end - start)
> + "ms");
> 
> First run is 433ms, second run is 137ms.

Essentially we're spending 300ms longer in the first run than the second. To me that implies that the first run doesn't get to jump into the optimized path. This is further reinforced if i increase the iteration count:

function f(j) { for (var i = 0 ; i < 500000000; i++) j = (j ?  j * i : 1) ^ (i & j); }; var start = new Date; f(); var end = new Date; print("1st: " + (end - start) + "ms"); var start = new Date; f(); var end = new Date; print("2nd: " + (end - start) + "ms");

Producing
1st: 18392ms
2nd: 4166ms

The scaling of runtime implies that the first run is not tiering up in any meaningful way, but we are producing code that is optimised: we hit it the second time we run the function.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20160316/3e17f508/attachment.html>


More information about the webkit-unassigned mailing list