Comment #1 on issue 2617 by [email protected]: Optimize parent scope
variable access
http://code.google.com/p/v8/issues/detail?id=2617
Hi folks,
I've tested similar test on an android device powered by snapdragon 800.
The test codes are like this...
function benchmark1() {
var sum = 0, i = 0;
(function bench() {
for (i = 0; i < 1000000000; i++) {
sum = (sum + i) | 0;
}
})();
return sum;
}
function benchmark2() {
var sum = 0, i = 0;
for (i = 0; i < 1000000000; i++) {
sum = (sum + i) | 0;
}
return sum;
}
The result is astounding.
* benchmark1: 27.65s
* benchmark2: 1.89s
The reason is too many GC(scavenger) are triggered in benchmark1, while not
a single GC run is seen in benchmark2.
So I investigated this a little more.
Here is a part of generated code(the part of "sum = (sum + i) | 0;").
;;; <@62,#55> add-i
0x5d061b18 152 e0822003 add r2, r2, r3
;;; <@64,#78> number-tag-i
0x5d061b1c 156 e0923002 adds r3, r2, r2 ;; debug:
position 121
0x5d061b20 160 6a000042 bvs +272 -> 432 (0x5d061c30)
before line 152, r2 and r3 have value of i and sum respectively.
Line 156 tries to convert `sum` into smi, it sometimes fails, goes to
deferred-number-tag-i(line 432) that allocates new heap number.
Thus every iteration in the loop the updated `sum` is not matched for smi,
new heap number is generated. Leads too many scavenger.
I think reusing heap number object solves this problem.
Or maybe we can even do this without a heap number because we actually
don't need to update sum(context slot) in the loop, just update it before
return?
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.