mirror of
https://github.com/nodejs/node.git
synced 2025-05-21 08:57:07 +00:00

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: https://github.com/nodejs/node/pull/2694 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
62 lines
1.8 KiB
JavaScript
62 lines
1.8 KiB
JavaScript
'use strict';
|
|
var fs = require('fs');
|
|
var assert = require('assert');
|
|
var path = require('path');
|
|
var cp = require('child_process');
|
|
var common = require('../common');
|
|
|
|
common.refreshTmpDir();
|
|
process.chdir(common.tmpDir);
|
|
var processor =
|
|
path.join(common.testDir, '..', 'tools', 'v8-prof', getScriptName());
|
|
// Unknown checked for to prevent flakiness, if pattern is not found,
|
|
// then a large number of unknown ticks should be present
|
|
runTest(/LazyCompile.*\[eval\]:1|.*% UNKNOWN/,
|
|
`function f() {
|
|
for (var i = 0; i < 1000000; i++) {
|
|
i++;
|
|
}
|
|
setImmediate(function() { f(); });
|
|
};
|
|
setTimeout(function() { process.exit(0); }, 2000);
|
|
f();`);
|
|
if (process.platform === 'win32' ||
|
|
process.platform === 'sunos' ||
|
|
process.platform === 'freebsd') {
|
|
console.log('1..0 # Skipped: C++ symbols are not mapped for this os.');
|
|
return;
|
|
}
|
|
runTest(/RunInDebugContext/,
|
|
`function f() {
|
|
require(\'vm\').runInDebugContext(\'Debug\');
|
|
setImmediate(function() { f(); });
|
|
};
|
|
setTimeout(function() { process.exit(0); }, 2000);
|
|
f();`);
|
|
|
|
function runTest(pattern, code) {
|
|
cp.execFileSync(process.execPath, ['-prof', '-pe', code]);
|
|
var matches = fs.readdirSync(common.tmpDir).filter(function(file) {
|
|
return /^isolate-/.test(file);
|
|
});
|
|
if (matches.length != 1) {
|
|
assert.fail('There should be a single log file.');
|
|
}
|
|
var log = matches[0];
|
|
var out = cp.execSync(processor + ' --call-graph-size=10 ' + log,
|
|
{encoding: 'utf8'});
|
|
assert(out.match(pattern));
|
|
fs.unlinkSync(log);
|
|
}
|
|
|
|
function getScriptName() {
|
|
switch (process.platform) {
|
|
case 'darwin':
|
|
return 'mac-tick-processor';
|
|
case 'win32':
|
|
return 'windows-tick-processor.bat';
|
|
default:
|
|
return 'linux-tick-processor';
|
|
}
|
|
}
|