- 
    Type:Improvement 
- 
    Resolution: Unresolved
- 
    Priority:Major - P3 
- 
    None
- 
    Affects Version/s: None
- 
    Component/s: None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
const doc = cursor[kDocuments].shift();
In V8, Array.prototype.shift() potentially copies the entirety of the array forward by one element, leading to bad performance for large batch sizes (which we tried using as part of investigating COMPASS-5455 – see attached CPU profile which points to unreasonably much time being spent in nextDocument). Specifically, fetching documents happens in O(nDocuments · batchSize) rather than the expectable O(nDocuments).
If this is adjusted to perform plain array accesses instead of .shift() calls, performance is as expected.
- depends on
- 
                    NODE-3977 Investigate NODE-3976 - .shift() usage in nextDocument greatly slows down with large batchSize -         
- Closed
 
-         
- is related to
- 
                    NODE-4350 Address performance regression of parsing large buffers -         
- Closed
 
-         
- 
                    NODE-4635 Migrate deque from denque to Js-sdsl Deque -         
- Closed
 
-         
- related to
- 
                    COMPASS-5455 Export records is slow -         
- Closed
 
-         
