Skip to content

Commit

Permalink
fix: revert use of setImmediate to process.nextTick (#2611)
Browse files Browse the repository at this point in the history
A performance regression was identified in switching the connection
pool to using setImmediate instead of process.nextTick for wait
queue processing. This patch reverts that change.

NODE-2861
  • Loading branch information
mbroadst authored Nov 6, 2020
1 parent 89b77ed commit c9f9d5e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/cmap/connection_pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class ConnectionPool extends EventEmitter {
}

this[kWaitQueue].push(waitQueueMember);
setImmediate(() => processWaitQueue(this));
process.nextTick(() => processWaitQueue(this));
}

/**
Expand All @@ -258,7 +258,7 @@ class ConnectionPool extends EventEmitter {
destroyConnection(this, connection, reason);
}

setImmediate(() => processWaitQueue(this));
process.nextTick(() => processWaitQueue(this));
}

/**
Expand Down Expand Up @@ -428,7 +428,7 @@ function createConnection(pool, callback) {

// otherwise add it to the pool for later acquisition, and try to process the wait queue
pool[kConnections].push(connection);
setImmediate(() => processWaitQueue(pool));
process.nextTick(() => processWaitQueue(pool));
});
}

Expand All @@ -439,7 +439,7 @@ function destroyConnection(pool, connection, reason) {
pool[kPermits]++;

// destroy the connection
setImmediate(() => connection.destroy());
process.nextTick(() => connection.destroy());
}

function processWaitQueue(pool) {
Expand Down

0 comments on commit c9f9d5e

Please sign in to comment.