[SERVER-9267] Issues with readonly BSON in v8 Created: 05/Apr/13  Updated: 11/Jul/16  Resolved: 08/Apr/13

Status: Closed
Project: Core Server
Component/s: JavaScript
Affects Version/s: None
Fix Version/s: 2.4.2, 2.5.0

Type: Bug Priority: Major - P3
Reporter: Mathias Stearn Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-9051 v8 heap allocation failure can lead t... Closed
Operating System: ALL
Participants:

 Description   

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:

  1. this.x != this.x if x is an Object
  2. 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]);
}



 Comments   
Comment by auto [ 06/Apr/13 ]

Author:

{u'date': u'2013-04-05T20:19:25Z', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: SERVER-9267 Make readonly v8 objects use same getters as regular lazy objects

Also fixes SERVER-9251
Branch: v2.4
https://github.com/mongodb/mongo/commit/1a6239025624c7660b65970d3258f1a242ab4512

Comment by auto [ 05/Apr/13 ]

Author:

{u'date': u'2013-04-05T20:19:25Z', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: SERVER-9267 Make readonly v8 objects use same getters as regular lazy objects

Also fixes SERVER-9251
Branch: master
https://github.com/mongodb/mongo/commit/be6a5bbdca5b7b0566d043b6d7cea289743812d1

Generated at Thu Feb 08 03:19:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.