-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: JavaScript
-
None
-
ALL
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Read-only objects don't cache the converted v8 values and reconvert every time a field is accessed. This causes the following two major issues:
- this.x != this.x if x is an Object
- Since arrays are not lazy we need to build the entire thing each time we access. This is ok if the array is assigned to a variable then accessed through it but causes O(n^2) performance when accessed through a readonly object.
Example:
function mapFast() { // O(n)
var array = this.array;
for (var i=0; i<array.length; i++)
emit(null, array[i]);
}
function mapSlow() { // O(n^2)
for (var i=0; i<this.array.length; i++)
emit(null, this.array[i]);
}
- is related to
-
SERVER-9051 v8 heap allocation failure can lead to segfault
-
- Closed
-