GeezerVison is showing github.com — tools: add --prof-process flag to node binary · tmarshall/node@49440b7
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .eslintignore +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +lib/internal/v8_prof_polyfill.js | 1 | 2 | lib/punycode.js | 2 | 3 | test/addons/doc-*/ | 3 | 4 | test/fixtures | |
Collapse file Copy file name to clipboardExpand all lines: doc/node.1 +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -64,6 +64,8 @@ and servers. | 64 | 64 |
| 65 | 65 | --track-heap-objects track heap object allocations for heap snapshots | 66 | 66 |
| | 67 | + --prof-process process v8 profiler output generated using --prof | | 68 | + | 67 | 69 | --v8-options print v8 command line options | 68 | 70 |
| 69 | 71 | --tls-cipher-list=list use an alternative default TLS cipher list | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/v8_prof_polyfill.js +8-1Lines changed: 8 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -50,7 +50,14 @@ arguments = process.argv.slice(2); | 50 | 50 | var quit = process.exit; | 51 | 51 |
| 52 | 52 | // Polyfill "readline()". | 53 | | -var fd = fs.openSync(arguments[arguments.length - 1], 'r'); | | 53 | +var logFile = arguments[arguments.length - 1]; | | 54 | +try { | | 55 | + fs.accessSync(logFile); | | 56 | +} catch(e) { | | 57 | + console.error('Please provide a valid isolate file as the final argument.'); | | 58 | + process.exit(1); | | 59 | +} | | 60 | +var fd = fs.openSync(logFile, 'r'); | 54 | 61 | var buf = new Buffer(4096); | 55 | 62 | var dec = new (require('string_decoder').StringDecoder)('utf-8'); | 56 | 63 | var line = ''; | |
Collapse file Copy file name to clipboard +44Lines changed: 44 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +'use strict'; | | 2 | +var cp = require('child_process'); | | 3 | +var fs = require('fs'); | | 4 | +var path = require('path'); | | 5 | + | | 6 | +var scriptFiles = [ | | 7 | + 'internal/v8_prof_polyfill', | | 8 | + 'v8/tools/splaytree', | | 9 | + 'v8/tools/codemap', | | 10 | + 'v8/tools/csvparser', | | 11 | + 'v8/tools/consarray', | | 12 | + 'v8/tools/profile', | | 13 | + 'v8/tools/profile_view', | | 14 | + 'v8/tools/logreader', | | 15 | + 'v8/tools/tickprocessor', | | 16 | + 'v8/tools/SourceMap', | | 17 | + 'v8/tools/tickprocessor-driver' | | 18 | +]; | | 19 | +var tempScript = 'tick-processor-tmp-' + process.pid; | | 20 | +var tempNm = 'mac-nm-' + process.pid; | | 21 | + | | 22 | +process.on('exit', function() { | | 23 | + try { fs.unlinkSync(tempScript); } catch (e) {} | | 24 | + try { fs.unlinkSync(tempNm); } catch (e) {} | | 25 | +}); | | 26 | +process.on('uncaughtException', function(err) { | | 27 | + try { fs.unlinkSync(tempScript); } catch (e) {} | | 28 | + try { fs.unlinkSync(tempNm); } catch (e) {} | | 29 | + throw err; | | 30 | +}); | | 31 | + | | 32 | +scriptFiles.forEach(function(script) { | | 33 | + fs.appendFileSync(tempScript, process.binding('natives')[script]); | | 34 | +}); | | 35 | +var tickArguments = [tempScript]; | | 36 | +if (process.platform === 'darwin') { | | 37 | + fs.writeFileSync(tempNm, process.binding('natives')['v8/tools/mac-nm'], | | 38 | + { mode: 0o555 }); | | 39 | + tickArguments.push('--mac', '--nm=' + path.join(process.cwd(), tempNm)); | | 40 | +} else if (process.platform === 'win32') { | | 41 | + tickArguments.push('--windows'); | | 42 | +} | | 43 | +tickArguments.push.apply(tickArguments, process.argv.slice(1)); | | 44 | +cp.spawn(process.execPath, tickArguments, { stdio: 'inherit' }); |
Collapse file Copy file name to clipboardExpand all lines: node.gyp +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 78 | 78 | 'lib/internal/repl.js', | 79 | 79 | 'lib/internal/socket_list.js', | 80 | 80 | 'lib/internal/util.js', | | 81 | + 'lib/internal/v8_prof_polyfill.js', | | 82 | + 'lib/internal/v8_prof_processor.js', | 81 | 83 | 'lib/internal/streams/lazy_transform.js', | | 84 | + 'deps/v8/tools/splaytree.js', | | 85 | + 'deps/v8/tools/codemap.js', | | 86 | + 'deps/v8/tools/consarray.js', | | 87 | + 'deps/v8/tools/csvparser.js', | | 88 | + 'deps/v8/tools/profile.js', | | 89 | + 'deps/v8/tools/profile_view.js', | | 90 | + 'deps/v8/tools/logreader.js', | | 91 | + 'deps/v8/tools/tickprocessor.js', | | 92 | + 'deps/v8/tools/SourceMap.js', | | 93 | + 'deps/v8/tools/tickprocessor-driver.js', | | 94 | + 'deps/v8/tools/mac-nm', | 82 | 95 | ], | 83 | 96 | }, | 84 | 97 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/node.cc +13-1Lines changed: 13 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -144,6 +144,7 @@ static const char** preload_modules = nullptr; | 144 | 144 | static bool use_debug_agent = false; | 145 | 145 | static bool debug_wait_connect = false; | 146 | 146 | static int debug_port = 5858; | | 147 | +static bool prof_process = false; | 147 | 148 | static bool v8_is_profiling = false; | 148 | 149 | static bool node_is_initialized = false; | 149 | 150 | static node_module* modpending; | @@ -2958,6 +2959,11 @@ void SetupProcessObject(Environment* env, | 2958 | 2959 | READONLY_PROPERTY(process, "throwDeprecation", True(env->isolate())); | 2959 | 2960 | } | 2960 | 2961 |
| | 2962 | + // --prof-process | | 2963 | + if (prof_process) { | | 2964 | + READONLY_PROPERTY(process, "profProcess", True(env->isolate())); | | 2965 | + } | | 2966 | + | 2961 | 2967 | // --trace-deprecation | 2962 | 2968 | if (trace_deprecation) { | 2963 | 2969 | READONLY_PROPERTY(process, "traceDeprecation", True(env->isolate())); | @@ -3195,6 +3201,8 @@ static void PrintHelp() { | 3195 | 3201 | " is detected after the first tick\n" | 3196 | 3202 | " --track-heap-objects track heap object allocations for heap " | 3197 | 3203 | "snapshots\n" | | 3204 | + " --prof-process process v8 profiler output generated\n" | | 3205 | + " using --prof\n" | 3198 | 3206 | " --v8-options print v8 command line options\n" | 3199 | 3207 | #if HAVE_OPENSSL | 3200 | 3208 | " --tls-cipher-list=val use an alternative default TLS cipher list\n" | @@ -3266,7 +3274,8 @@ static void ParseArgs(int* argc, | 3266 | 3274 | new_argv[0] = argv[0]; | 3267 | 3275 |
| 3268 | 3276 | unsigned int index = 1; | 3269 | | - while (index < nargs && argv[index][0] == '-') { | | 3277 | + bool short_circuit = false; | | 3278 | + while (index < nargs && argv[index][0] == '-' && !short_circuit) { | 3270 | 3279 | const char* const arg = argv[index]; | 3271 | 3280 | unsigned int args_consumed = 1; | 3272 | 3281 |
| @@ -3327,6 +3336,9 @@ static void ParseArgs(int* argc, | 3327 | 3336 | track_heap_objects = true; | 3328 | 3337 | } else if (strcmp(arg, "--throw-deprecation") == 0) { | 3329 | 3338 | throw_deprecation = true; | | 3339 | + } else if (strcmp(arg, "--prof-process") == 0) { | | 3340 | + prof_process = true; | | 3341 | + short_circuit = true; | 3330 | 3342 | } else if (strcmp(arg, "--v8-options") == 0) { | 3331 | 3343 | new_v8_argv[new_v8_argc] = "--help"; | 3332 | 3344 | new_v8_argc += 1; | |
Collapse file Copy file name to clipboardExpand all lines: src/node.js +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 71 | 71 | var d = NativeModule.require('_debug_agent'); | 72 | 72 | d.start(); | 73 | 73 |
| | 74 | + } else if (process.profProcess) { | | 75 | + NativeModule.require('internal/v8_prof_processor'); | | 76 | + | 74 | 77 | } else { | 75 | 78 | // There is user code to be run | 76 | 79 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-tick-processor.js +3-5Lines changed: 3 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -7,8 +7,6 @@ var common = require('../common'); | 7 | 7 |
| 8 | 8 | common.refreshTmpDir(); | 9 | 9 | process.chdir(common.tmpDir); | 10 | | -var processor = | 11 | | - path.join(common.testDir, '..', 'tools', 'v8-prof', 'tick-processor.js'); | 12 | 10 | // Unknown checked for to prevent flakiness, if pattern is not found, | 13 | 11 | // then a large number of unknown ticks should be present | 14 | 12 | runTest(/LazyCompile.*\[eval\]:1|.*% UNKNOWN/, | @@ -45,9 +43,9 @@ function runTest(pattern, code) { | 45 | 43 | assert.fail(null, null, 'There should be a single log file.'); | 46 | 44 | } | 47 | 45 | var log = matches[0]; | 48 | | - var out = cp.execSync(process.execPath + ' ' + processor + | 49 | | - ' --call-graph-size=10 ' + log, | | 46 | + var out = cp.execSync(process.execPath + | | 47 | + ' --prof-process --call-graph-size=10 ' + log, | 50 | 48 | {encoding: 'utf8'}); | 51 | | - assert(out.match(pattern)); | | 49 | + assert(pattern.test(out)); | 52 | 50 | fs.unlinkSync(log); | 53 | 51 | } |
Collapse file Copy file name to clipboardExpand all lines: tools/install.py -44Lines changed: 0 additions & 44 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -127,48 +127,6 @@ def subdir_files(path, dest, action): | 127 | 127 | for subdir, files in ret.items(): | 128 | 128 | action(files, subdir + '/') | 129 | 129 |
| 130 | | -def build_tick_processor(action): | 131 | | - tmp_script = 'out/Release/tick-processor' | 132 | | - if action == install: | 133 | | - # construct script | 134 | | - scripts = [ | 135 | | - 'tools/v8-prof/polyfill.js', | 136 | | - 'deps/v8/tools/splaytree.js', | 137 | | - 'deps/v8/tools/codemap.js', | 138 | | - 'deps/v8/tools/csvparser.js', | 139 | | - 'deps/v8/tools/consarray.js', | 140 | | - 'deps/v8/tools/csvparser.js', | 141 | | - 'deps/v8/tools/consarray.js', | 142 | | - 'deps/v8/tools/profile.js', | 143 | | - 'deps/v8/tools/profile_view.js', | 144 | | - 'deps/v8/tools/logreader.js', | 145 | | - 'deps/v8/tools/tickprocessor.js', | 146 | | - 'deps/v8/tools/SourceMap.js', | 147 | | - 'deps/v8/tools/tickprocessor-driver.js'] | 148 | | - args = [] | 149 | | - if sys.platform == 'win32': | 150 | | - args.append('--windows') | 151 | | - elif sys.platform == 'darwin': | 152 | | - args.append('--nm=' + abspath(install_path, 'share/doc/node') + '/mac-nm') | 153 | | - args.append('--mac') | 154 | | - with open(tmp_script, 'w') as out_file: | 155 | | - # Add #! line to run with node | 156 | | - out_file.write('#! ' + abspath(install_path, 'bin/node') + '\n') | 157 | | - # inject arguments | 158 | | - for arg in args: | 159 | | - out_file.write('process.argv.splice(2, 0, \'' + arg + '\');\n') | 160 | | - # cat in source files | 161 | | - for script in scripts: | 162 | | - with open(script) as in_file: | 163 | | - shutil.copyfileobj(in_file, out_file) | 164 | | - # make executable | 165 | | - st = os.stat(tmp_script) | 166 | | - os.chmod(tmp_script, st.st_mode | stat.S_IEXEC) | 167 | | - # perform installations | 168 | | - action([tmp_script], 'share/doc/node/') | 169 | | - if sys.platform == 'darwin': | 170 | | - action(['deps/v8/tools/mac-nm'], 'share/doc/node/') | 171 | | - | 172 | 130 | def files(action): | 173 | 131 | is_windows = sys.platform == 'win32' | 174 | 132 |
| @@ -183,8 +141,6 @@ def files(action): | 183 | 141 |
| 184 | 142 | action(['deps/v8/tools/gdbinit'], 'share/doc/node/') | 185 | 143 |
| 186 | | - build_tick_processor(action) | 187 | | - | 188 | 144 | if 'freebsd' in sys.platform or 'openbsd' in sys.platform: | 189 | 145 | action(['doc/node.1'], 'man/man1/') | 190 | 146 | else: | |
Collapse file Copy file name to clipboardExpand all lines: tools/js2c.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -310,7 +310,7 @@ def JS2C(source, target): | 310 | 310 | else: | 311 | 311 | ids.append((id, len(lines))) | 312 | 312 |
| 313 | | - escaped_id = id.replace('/', '_') | | 313 | + escaped_id = id.replace('-', '_').replace('/', '_') | 314 | 314 | source_lines.append(SOURCE_DECLARATION % { | 315 | 315 | 'id': id, | 316 | 316 | 'escaped_id': escaped_id, | |
|