Major - P3
The fix for https://jira.mongodb.org/browse/NODE-2803 introduced a noticable performance regression for all mongodb connections (queries, inserts, ...).
This performance hit is only visible, if the nodejs event loop is under pressure.
In the example in the linked ticket nothing happens but mongodb insert logic. This results in an average iteration duration of the event loop of around 1ms.
==> the setImmediate usage results in a 1ms delay before sending the request to mongodb (compared to 3.6.1)
But if the nodejs process (for example as a webserver) has multiple further things to do on the event loop (everything shortlived, fast, non blocking) this average iteration duration of the event loop can rise. For example to ~10ms.
==> the setImmediate usage results in a ~10ms delay before sending the request to mongodb (compared to 3.6.1) to get the next batch
This small delay adds up, most noticable for queries with cursors and multiple getMore-Roundtrips to Mongodb.
- is caused by
NODE-2803 Connection pool wait queue processing is too greedy