-
Type: Task
-
Resolution: Done
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
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!
- is depended on by
-
NODE-4283 Performance regression of parsing Array type fields
- Closed