Skip to content

Commit 519caba

Browse files
Matt LoringFishrock123
Matt Loring
authored andcommitted
tools: fix flakiness in test-tick-processor
Per the discussion on #2471, the JS symbols checked for by this test were occasionally too deep in the stack and were being ignored by the tick processor. I have addressed this by increasing the stack depth inspected by the tick processor and looking for the eval symbol which is more likely to be present. Additional flakiness was caused by occasional misses of the code creation event for the JS function being executed. I now have separate code snippets to test for JS and C++ symbols and if the code creation event is missed for the JS symbol test then I check for a percentage of UNKNOWN symbols in processed output. This is considered a success as the processing scripts in the node repository are still correctly processing the ticks recieved from the v8 scripts. Further investigation is needed into the v8 profiling scripts to determine why code creation events are being missed. PR-URL: #2694 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent e8a206e commit 519caba

File tree

2 files changed

+33
-18
lines changed

2 files changed

+33
-18
lines changed

test/parallel/parallel.status

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ test-tls-ticket-cluster : PASS,FLAKY
1212
[$system==linux]
1313
test-cluster-worker-forced-exit : PASS,FLAKY
1414
test-http-client-timeout-event : PASS,FLAKY
15-
test-tick-processor : PASS,FLAKY
1615
test-tls-no-sslv3 : PASS,FLAKY
1716
test-child-process-buffering : PASS,FLAKY
1817
test-child-process-exit-code : PASS,FLAKY

test/parallel/test-tick-processor.js

+33-17
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,48 @@ var cp = require('child_process');
66
var common = require('../common');
77

88
common.refreshTmpDir();
9-
109
process.chdir(common.tmpDir);
11-
cp.execFileSync(process.execPath, ['-prof', '-pe',
12-
'function foo(n) {' +
13-
'require(\'vm\').runInDebugContext(\'Debug\');' +
14-
'return n < 2 ? n : setImmediate(function() { foo(n-1) + foo(n-2);}); };' +
15-
'setTimeout(function() { process.exit(0); }, 2000);' +
16-
'foo(40);']);
17-
var matches = fs.readdirSync(common.tmpDir).filter(function(file) {
18-
return /^isolate-/.test(file);
19-
});
20-
if (matches.length != 1) {
21-
assert.fail('There should be a single log file.');
22-
}
23-
var log = matches[0];
2410
var processor =
2511
path.join(common.testDir, '..', 'tools', 'v8-prof', getScriptName());
26-
var out = cp.execSync(processor + ' ' + log, {encoding: 'utf8'});
27-
assert(out.match(/LazyCompile.*foo/));
12+
// Unknown checked for to prevent flakiness, if pattern is not found,
13+
// then a large number of unknown ticks should be present
14+
runTest(/LazyCompile.*\[eval\]:1|.*% UNKNOWN/,
15+
`function f() {
16+
for (var i = 0; i < 1000000; i++) {
17+
i++;
18+
}
19+
setImmediate(function() { f(); });
20+
};
21+
setTimeout(function() { process.exit(0); }, 2000);
22+
f();`);
2823
if (process.platform === 'win32' ||
2924
process.platform === 'sunos' ||
3025
process.platform === 'freebsd') {
3126
console.log('1..0 # Skipped: C++ symbols are not mapped for this os.');
3227
return;
3328
}
34-
assert(out.match(/RunInDebugContext/));
29+
runTest(/RunInDebugContext/,
30+
`function f() {
31+
require(\'vm\').runInDebugContext(\'Debug\');
32+
setImmediate(function() { f(); });
33+
};
34+
setTimeout(function() { process.exit(0); }, 2000);
35+
f();`);
36+
37+
function runTest(pattern, code) {
38+
cp.execFileSync(process.execPath, ['-prof', '-pe', code]);
39+
var matches = fs.readdirSync(common.tmpDir).filter(function(file) {
40+
return /^isolate-/.test(file);
41+
});
42+
if (matches.length != 1) {
43+
assert.fail('There should be a single log file.');
44+
}
45+
var log = matches[0];
46+
var out = cp.execSync(processor + ' --call-graph-size=10 ' + log,
47+
{encoding: 'utf8'});
48+
assert(out.match(pattern));
49+
fs.unlinkSync(log);
50+
}
3551

3652
function getScriptName() {
3753
switch (process.platform) {

0 commit comments

Comments
 (0)