-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: speed up process.getActiveResourcesInfo()
This change reduces the number of calls that were crossing the JS-C++ boundary to 1 and also removes the need for calling Array::New() multiple times internally and ArrayPrototypeConcat-ing the results later on, thus improving performance. Refs: #44445 (review) Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: #46014 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
- Loading branch information
Showing
9 changed files
with
103 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict'; | ||
|
||
const { createBenchmark } = require('../common.js'); | ||
|
||
const { connect, createServer } = require('net'); | ||
const { open } = require('fs'); | ||
|
||
const bench = createBenchmark(main, { | ||
handlesCount: [1e4], | ||
requestsCount: [1e4], | ||
timeoutsCount: [1e4], | ||
immediatesCount: [1e4], | ||
n: [1e5], | ||
}); | ||
|
||
function main({ handlesCount, requestsCount, timeoutsCount, immediatesCount, n }) { | ||
const server = createServer().listen(); | ||
const clients = []; | ||
for (let i = 0; i < handlesCount; i++) { | ||
clients.push(connect({ port: server.address().port })); | ||
} | ||
|
||
for (let i = 0; i < requestsCount; i++) { | ||
open(__filename, 'r', () => {}); | ||
} | ||
|
||
for (let i = 0; i < timeoutsCount; ++i) { | ||
setTimeout(() => {}, 1); | ||
} | ||
|
||
for (let i = 0; i < immediatesCount; ++i) { | ||
setImmediate(() => {}); | ||
} | ||
|
||
bench.start(); | ||
for (let i = 0; i < n; ++i) { | ||
process.getActiveResourcesInfo(); | ||
} | ||
bench.end(n); | ||
|
||
for (const client of clients) { | ||
client.destroy(); | ||
} | ||
server.close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters