From 4212a65498659f92f196569ee20e6ecf5d191fb4 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Fri, 19 Apr 2019 17:15:04 +0800 Subject: [PATCH 1/4] inspector: split --cpu-prof-path to --prof-dir and --cpu-prof-name To improve the integration of `--cpu-prof` with workers, this patch splits `--cpu-prof-path` into `--prof-dir` and `--cpu-prof-name`, so when a worker is launched from a thread that enables `--cpu-prof`, if the parent thread sets `--prof-dir`, then the profile of both thread would be generated to the specified directory. If they end up specifying the same `--cpu-prof-name` the behavior is undefined the last profile will overwritten the first one. --- doc/api/cli.md | 31 ++-- doc/node.1 | 18 ++- src/env-inl.h | 31 ++++ src/env.h | 6 + src/inspector_profiler.cc | 16 +- src/node.cc | 3 +- src/node_options.cc | 22 ++- src/node_options.h | 3 +- .../workload/fibonacci-worker-argv.js | 7 + test/fixtures/workload/fibonacci-worker.js | 4 +- test/sequential/test-cpu-prof.js | 147 +++++++++++++++--- 11 files changed, 233 insertions(+), 55 deletions(-) create mode 100644 test/fixtures/workload/fibonacci-worker-argv.js diff --git a/doc/api/cli.md b/doc/api/cli.md index c26177444c7894..23d2642cee575b 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -83,8 +83,13 @@ added: REPLACEME > Stability: 1 - Experimental Starts the V8 CPU profiler on start up, and writes the CPU profile to disk -before exit. If `--cpu-prof-path` is not specified, the profile will be -written to `${cwd}/CPU.${yyyymmdd}.${hhmmss}.${pid}.${tid}.${seq}.cpuprofile`. +before exit. + +If `--prof-dir` is not specified, the generated profile will be placed in the +current working directory. + +If `--cpu-prof-name` is not specified, the generated profile will be +named `CPU.${yyyymmdd}.${hhmmss}.${pid}.${tid}.${seq}.cpuprofile`. ```console $ node --cpu-prof index.js @@ -92,19 +97,14 @@ $ ls *.cpuprofile CPU.20190409.202950.15293.0.0.cpuprofile ``` -### `--cpu-prof-path` +### `--cpu-prof-name` > Stability: 1 - Experimental -Location where the CPU profile generated by `--cpu-prof` -should be written to. When used alone, it implies `--cpu-prof`. - -```console -$ node --cpu-prof-path /tmp/test.cpuprofile index.js -``` +Specify the file name of the CPU profile generated by `--cpu-prof`. ### `--diagnostic-report-directory=directory` + +> Stability: 1 - Experimental + +Specify the directory where the CPU profiles generated by `--cpu-prof` will +be placed. + +This does not apply to `--prof` whose output is handled by V8 instead of +Node.js. + ### `--prof-process` + +> Stability: 1 - Experimental + +Specify the directory where the CPU profiles generated by `--cpu-prof` will +be placed. + +This does not apply to `--prof` whose output is handled by V8 instead of +Node.js. + ### `--no-deprecation` - -> Stability: 1 - Experimental - -Specify the directory where the CPU profiles generated by `--cpu-prof` will -be placed. - -This does not apply to `--prof` whose output is handled by V8 instead of -Node.js. - ### `--prof-process` + +> Stability: 1 - Experimental + +Specify the directory where the CPU profiles generated by `--cpu-prof` will +be placed. + ### `--cpu-prof-name` - -> Stability: 1 - Experimental - -Specify the directory where the CPU profiles generated by `--cpu-prof` will -be placed. - -This does not apply to `--prof` whose output is handled by V8 instead of -Node.js. - ### `--no-deprecation`