-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 4.6.0
-
Component/s: BSON, Performance
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!
- depends on
-
NODE-4019 BSON V5
- Development Complete
-
NODE-4284 Investigate NODE-4283 - Performance regression of parsing Array type fields
- Closed
-
NODE-4350 Address performance regression of parsing large buffers
- Closed
- is duplicated by
-
NODE-4611 Performance-Regression - Simple Find Query - Node16 vs Node18
- Closed
- is related to
-
NODE-4635 Migrate deque from denque to Js-sdsl Deque
- Closed
-
NODE-5358 Address performance regressions introduced in bson v5.0.0
- Closed