From 49d3d11ba7975b2c6df4ecab55b4619da46fcb95 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Fri, 19 Apr 2019 17:15:04 +0800 Subject: [PATCH] inspector: split --cpu-prof-path to --cpu-prof-dir and --cpu-prof-name To improve the integration of `--cpu-prof` with workers, this patch splits `--cpu-prof-path` into `--cpu-prof-dir` and `--cpu-prof-name`, so when a worker is launched from a thread that enables `--cpu-prof`, if the parent thread sets `--cpu-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. PR-URL: https://github.com/nodejs/node/pull/27306 Reviewed-By: Anna Henningsen Reviewed-By: Matteo Collina --- doc/api/cli.md | 26 +++- doc/node.1 | 14 +- src/env-inl.h | 17 ++ src/env.cc | 18 +++ src/env.h | 6 + src/inspector_profiler.cc | 16 +- src/node.cc | 3 +- src/node_options.cc | 24 ++- 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 +++++++++++++++--- 12 files changed, 231 insertions(+), 54 deletions(-) create mode 100644 test/fixtures/workload/fibonacci-worker-argv.js diff --git a/doc/api/cli.md b/doc/api/cli.md index d1419e2ccc9ff9..fed5aa90aa3a8f 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 `--cpu-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,24 @@ $ ls *.cpuprofile CPU.20190409.202950.15293.0.0.cpuprofile ``` -### `--cpu-prof-path` +### `--cpu-prof-dir` > Stability: 1 - Experimental -Location where the CPU profile generated by `--cpu-prof` -should be written to. When used alone, it implies `--cpu-prof`. +Specify the directory where the CPU profiles generated by `--cpu-prof` will +be placed. -```console -$ node --cpu-prof-path /tmp/test.cpuprofile index.js -``` +### `--cpu-prof-name` + + +> Stability: 1 - Experimental + +Specify the file name of the CPU profile generated by `--cpu-prof`. ### `--enable-fips`