Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5e5af8b

Browse filesBrowse files
bzozevanlucas
authored andcommitted
benchmark: fix child-process-read on Windows
Under Windows 'ipc' communication requires the other process to format its messages with 'IPC framing protocol'. Otherwise, an assert is triggered in libuv. This commit changes child-process-read benchmark to use stdout to communicate with parent process. It also adds child-process-read-ipc.js to benchmark IPC communication using child node process. PR-URL: #6971 Reviewed-By: João Reis <reis@janeasystems.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 0fc8012 commit 5e5af8b
Copy full SHA for 5e5af8b

File tree

Expand file treeCollapse file tree

2 files changed

+47
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+47
-3
lines changed
Open diff view settings
Collapse file
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
if (process.argv[2] === 'child')
3+
{
4+
const len = +process.argv[3];
5+
const msg = `"${'.'.repeat(len)}"`;
6+
while (true) {
7+
process.send(msg);
8+
}
9+
} else {
10+
const common = require('../common.js');
11+
const bench = common.createBenchmark(main, {
12+
len: [64, 256, 1024, 4096, 32768],
13+
dur: [5]
14+
});
15+
const spawn = require('child_process').spawn;
16+
function main(conf) {
17+
bench.start();
18+
19+
const dur = +conf.dur;
20+
const len = +conf.len;
21+
22+
const options = { 'stdio': ['ignore', 'ignore', 'ignore', 'ipc'] };
23+
const child = spawn(process.argv[0],
24+
[process.argv[1], 'child', len], options);
25+
26+
var bytes = 0;
27+
child.on('message', function(msg) {
28+
bytes += msg.length;
29+
});
30+
31+
setTimeout(function() {
32+
child.kill();
33+
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
34+
bench.end(gbits);
35+
}, dur * 1000);
36+
}
37+
}
Collapse file

‎benchmark/child_process/child-process-read.js‎

Copy file name to clipboardExpand all lines: benchmark/child_process/child-process-read.js
+10-3Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
'use strict';
22
const common = require('../common.js');
3+
const os = require('os');
4+
5+
var messagesLength = [64, 256, 1024, 4096];
6+
// Windows does not support that long arguments
7+
if (os.platform() !== 'win32')
8+
messagesLength.push(32768);
9+
310
const bench = common.createBenchmark(main, {
4-
len: [64, 256, 1024, 4096, 32768],
11+
len: messagesLength,
512
dur: [5]
613
});
714

@@ -13,11 +20,11 @@ function main(conf) {
1320
const len = +conf.len;
1421

1522
const msg = '"' + Array(len).join('.') + '"';
16-
const options = {'stdio': ['ignore', 'ipc', 'ignore']};
23+
const options = { 'stdio': ['ignore', 'pipe', 'ignore'] };
1724
const child = spawn('yes', [msg], options);
1825

1926
var bytes = 0;
20-
child.on('message', function(msg) {
27+
child.stdout.on('data', function(msg) {
2128
bytes += msg.length;
2229
});
2330

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.