Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4284

Investigate NODE-4283 - Performance regression of parsing Array type fields

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • 2
    • Not Needed

      NODE-4283 Description
      After updating MongoDB Node.js driver from v3.7.3 to v4.6.0 in our Node.js app, I've noticed a performance regression of the app's endpoints. After investigating the regression I've figured out that deserialization of documents with array type fields containing multiple elements has noticeably degraded.

      I've managed to reproduce the regression by concurrently fetching 10k documents containing array type field with 20 string elements. Here are the repositories with the benchmark that helps to reproduce the performance regression:

      https://github.com/baryshok/mongodb-fetch-arrays-driver-v3
      https://github.com/baryshok/mongodb-fetch-arrays-driver-v4

      On driver v3 the execution time of the benchmark for 300 concurrent requests takes ~30 seconds whereas on driver v4 it takes ~50 seconds:
       

       

      I took measurements for different number of concurrent requests and put them into a chart to illustrate the scales of the regression better:
       

      The measurements were taken on Node.js v14.18.3 server, but I've briefly checked it on the latest releases of v16 and v18 as well and the results correlate with the ones from v14 (they are even worse in those versions, by the way).

      The most noticeable difference in the CPU profiles for the 300 concurrent requests benchmark is that in driver v3 Garbage Collection takes ~9 seconds whereas on driver v4 it takes ~25 seconds:
       

       
      Driver v4
       

       
      Driver v3
       

       
      MongoDB Server v5.0.7
       
      I hope it's possible to figure out what's causing the Garbage Collection to take so much more time than before and improve it. Thanks!

        1. driver-3.7.3-fetch-10000-docs-300-times-1653993002832.cpuprofile
          551 kB
          PM Bot
        2. driver-4.6.0-fetch-10000-docs-300-times-1653993054277.cpuprofile
          574 kB
          PM Bot
        3. image-2022-05-31-15-52-28-389.png
          29 kB
          PM Bot
        4. image-2022-05-31-15-53-23-777.png
          30 kB
          PM Bot
        5. image-2022-05-31-15-54-02-280.png
          110 kB
          PM Bot
        6. image-2022-05-31-15-57-38-591.png
          446 kB
          PM Bot
        7. image-2022-05-31-15-59-00-904.png
          212 kB
          PM Bot
        8. image-2022-05-31-15-59-34-443.png
          162 kB
          PM Bot

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            dbeng-pm-bot PM Bot
            Durran Jordan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: