summaryrefslogtreecommitdiff
path: root/src/inspector_profiler.cc
AgeCommit message (Collapse)Author
2019-11-06src: make EndStartedProfilers an exit hookAnna Henningsen
Run `EndStartedProfilers` on Environment teardown. This is part of a series of changes to make embedding easier, by requiring fewer internal methods to build a fully functioning Node.js instance. PR-URL: https://github.com/nodejs/node/pull/30229 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com>
2019-09-26src: fix compiler warning in inspector_profiler.ccDaniel Bevenius
Currently, the following compiler warnings is generated: ../src/inspector_profiler.cc:231:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result] profile->Set(context, FIXED_ONE_BYTE_STRING(isolate, "source-map-cache") ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 warning generated. This commit adds a .ToChecked() call to avoid the warning. PR-URL: https://github.com/nodejs/node/pull/29660 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-09-22process: initial SourceMap support via NODE_V8_COVERAGEBenjamin Coe
PR-URL: https://github.com/nodejs/node/pull/28960 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com>
2019-09-12src: modified RealEnvStore methods to use libuv functionsDevendra Satram
Modified RealEnvStore::Get, Set, Query and Delete methods to use libuv methods environment variables operations instead of using os specific logic and switches. Fixes: https://github.com/nodejs/node/issues/27211 Refs: http://docs.libuv.org/en/v1.x/misc.html PR-URL: https://github.com/nodejs/node/pull/27310 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-08-11src: organize imports in inspector_profiler.ccpi1024e
In the other .cc files in the project, includes are in alphabetical order, with local files first, and libraries after. However, inspector_profiler.cc has a library declared in the middle of the import order, and v8 is the second to last being imported, instead of the last. So I reordered the imports and testing showed no side effects; everything passed. PR-URL: https://github.com/nodejs/node/pull/29073 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2019-06-19src: fall back to env->exec_path() for default profile directoryJoyee Cheung
When the current working directory is deleted, fall back to exec_path as the default profile directory. PR-URL: https://github.com/nodejs/node/pull/28252 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-05-26inspector: implement --heap-profJoyee Cheung
In addition implements --heap-prof-name, --heap-prof-dir and --heap-prof-interval. These flags are similar to --cpu-prof flags but they are meant for the V8 sampling heap profiler instead of the CPU profiler. PR-URL: https://github.com/nodejs/node/pull/27596 Fixes: https://github.com/nodejs/node/issues/27421 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-05-26src: move DiagnosticFilename inlines into a -inl.hSam Roberts
DiagnosticFilename's constructor default values use inlines from env-inl.h, causing the many users of node_internals.h to include env-inl.h, even if they never use DiagnosticFilename. PR-URL: https://github.com/nodejs/node/pull/27839 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-05-23src: remove memory_tracker-inl.h from header filesSam Roberts
Inline headers should only be included into the .cc files that use them. PR-URL: https://github.com/nodejs/node/pull/27755 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-05-19inspector: fix typogengjiawen
PR-URL: https://github.com/nodejs/node/pull/27712 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-05-13src: remove util-inl.h from header filesSam Roberts
Its intended that *-inl.h header files are only included into the src files that call the inline methods. Explicitly include it into the files that need it. PR-URL: https://github.com/nodejs/node/pull/27631 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-05-11src: extract common macro to util.hgengjiawen
PR-URL: https://github.com/nodejs/node/pull/27512 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-05-05inspector: implement --cpu-prof-intervalJoyee Cheung
This patch implements --cpu-prof-interval to specify the sampling interval of the CPU profiler started by --cpu-prof from the command line. Also adjust the interval to 100 in test-cpu-prof.js to make the test less flaky - it would fail if the time taken to finish the workload is smaller than the sampling interval, which was more likely on powerful machines when the interval was 1000. PR-URL: https://github.com/nodejs/node/pull/27535 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-05-05src: refactor V8ProfilerConnection::DispatchMessage()Joyee Cheung
- Auto-generate the message id and return it for future use (we can always parse the response to find the message containing the profile instead of relying on the inspector connection being synchornous). - Generate the message from method and parameter strings and create a `StringView` directly to avoid the unnecessary copy in `ToProtocolString()`. PR-URL: https://github.com/nodejs/node/pull/27535 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-05-02src: refactor V8ProfilerConnection to be more reusableJoyee Cheung
Now the subclasses only need to override methods to - Get the profile node from the profiler response message object - Return the directory and file path And the V8ProfilerConnection() would handle the rest of profile serialization and message parsing. This makes it easier to add other types of profiles in the future. PR-URL: https://github.com/nodejs/node/pull/27475 Refs: https://github.com/nodejs/node/issues/27421 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-05-02src: refactor profile initializationJoyee Cheung
- Process and store --cpu-prof-dir and --cpu-prof-name during Environment creation - Start profilers in one `profiler::StartProfilers()` PR-URL: https://github.com/nodejs/node/pull/27475 Refs: https://github.com/nodejs/node/issues/27421 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-04-23inspector: split --cpu-prof-path to --cpu-prof-dir and --cpu-prof-nameJoyee Cheung
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 <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-04-19inspector: implement --cpu-prof[-path]Joyee Cheung
This patch introduces a CLI flag --cpu-prof that starts the V8 CPU profiler on start up, and ends the profiler then writes the CPU profile before the Node.js instance (on the main thread or the worker thread) exits. By default the profile is written to `${cwd}/CPU.${yyyymmdd}.${hhmmss}.${pid}.${tid}.${seq}.cpuprofile`. The patch also introduces a --cpu-prof-path flag for the user to specify the path the profile will be written to. Refs: https://github.com/nodejs/node/issues/26878 PR-URL: https://github.com/nodejs/node/pull/27147 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-04-06src: port coverage serialization to C++Joyee Cheung
This patch moves the serialization of coverage profiles into C++. With this we no longer need to patch `process.reallyExit` and hook into the exit events, but instead hook into relevant places in C++ which are safe from user manipulation. This also makes the code easier to reuse for other types of profiles. PR-URL: https://github.com/nodejs/node/pull/26874 Reviewed-By: Ben Coe <bencoe@gmail.com>
2019-03-12src: refactor coverage connectionJoyee Cheung
- Refactor the C++ class to be resuable for other types of profiles - Move the try-catch block around coverage collection callback to be inside the callback to silence potential JSON or write errors. - Use Function::Call instead of MakeCallback to call the coverage message callback since it does not actually need async hook handling. This way we no longer needs to disable the async hooks when writing the coverage results. - Renames `lib/internal/coverage-gen/with_profiler.js` to `lib/internal/profiler.js` because it is now the only way to generate coverage. PR-URL: https://github.com/nodejs/node/pull/26513 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Coe <bencoe@gmail.com>