Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-9267

Issues with readonly BSON in v8

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 2.4.2, 2.5.0
    • JavaScript
    • None
    • ALL

    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]);
      }

      Attachments

        Issue Links

          Activity

            People

              mathias@mongodb.com Mathias Stearn
              mathias@mongodb.com Mathias Stearn
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: