Status: New
Owner: ----
New issue 3828 by [email protected]: Small typed arrays are slower to
access than large typed arrays
https://code.google.com/p/v8/issues/detail?id=3828
I wrote a benchmark to understand the cost of polymorphism due to the
big/small typed array split, and I was surprised to see that (monomorphic)
access to small typed arrays is a bit more expensive that for large arrays!
I think this is because HLoadKeyed::InferRange handles EXTERNAL_*_ELEMENTS
but not *_ELEMENTS, so extra overflow checks are necessary for the
non-EXTERNAL case.
For the repro below (run multiple times to get different combinations of
<64 and >=64 lengths) I get ~1.33 for monomorphic small, ~1.19 for
monomorphic large, and ~2.8 for polymorphic.
//////////// REPRO
var time = (this.performance && this.performance.now) ||
this.dateNow || function() { return Date.now(); };
function arrSum(arr, n) {
var sum = 0;
for (var i = 0; i < n - 2; i++) {
sum += (arr[i] + arr[i+1]) * arr[i+2];
}
return sum;
}
function test1(arrs) {
var subtotal = 0;
for (var i = 0; i < 20000; i++) {
// Run the function over the first 30 elements of the array, regardless
of
// actuall size (it will always be >= 30).
subtotal += arrSum(arrs[i%2], 30);
}
return subtotal;
}
var arrs = [
new Uint8Array(Math.floor(30 + Math.random() * 60)),
new Uint8Array(Math.floor(30 + Math.random() * 60))
];
print('Testing with arrays sizes: ' + arrs[0].length + ' and ' +
arrs[1].length);
(function() {
var total = 0;
for (var i = 0; i < 15; i++) {
var before = time();
total += test1(arrs);
var after = time();
print(after - before);
}
print(total);
})();
--
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.