Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inspector: split --cpu-prof-path to --cpu-prof-dir and --cpu-prof-name #27306

Closed
wants to merge 4 commits into from

Conversation

joyeecheung
Copy link
Member

@joyeecheung joyeecheung commented Apr 19, 2019

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.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. labels Apr 19, 2019
@nodejs-github-bot

This comment has been minimized.

@joyeecheung
Copy link
Member Author

cc @nodejs/workers @nodejs/performance @nodejs/process

src/env-inl.h Outdated Show resolved Hide resolved
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mscdex
Copy link
Contributor

mscdex commented Apr 19, 2019

Why --prof-dir instead of something more specific like --cpu-prof-dir ? Having non-V8 --prof-* options is confusing because we already have --prof and --prof-process for V8.

src/node_options.cc Outdated Show resolved Hide resolved
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.
@mscdex
Copy link
Contributor

mscdex commented Apr 19, 2019

I prefer keeping the specific directory prefix in the flag names for clarity. If we support more profile types in the future it just gives more flexibility.

@joyeecheung
Copy link
Member Author

joyeecheung commented Apr 19, 2019

I prefer keeping the specific directory prefix in the flag names for clarity. If we support more profile types in the future it just gives more flexibility.

How would that gives more flexibility? If the whole path is specified in the flag, how would --cpu-prof-path work with workers? With --cpu-prof-path, you either hard-code the entire path, or nothing at all. With --prof-dir and --cpu-prof-name you can just hard-code the directory but let Node.js generate the file name for you, which I believe is the more common use case.

BTW, this is also closer to how the reports are generated. I think it's better to have a consistent style to generate these files.

@nodejs-github-bot

This comment has been minimized.

@joyeecheung
Copy link
Member Author

Moved the directory initialization to env.cc and renamed --prof-dir to --node-prof-dir to avoid the ambiguity. @mcollina @addaleax @mscdex PTAL, thanks!

@mscdex
Copy link
Contributor

mscdex commented Apr 19, 2019

With --cpu-prof-path, you either hard-code the entire path, or nothing at all.

I was referring to having individual profile type directory prefix flags like --cpu-prof-dir vs a --prof-dir for all profile types.

@joyeecheung
Copy link
Member Author

I was referring to having individual profile type directory prefix flags like --cpu-prof-dir vs a --prof-dir for all profile types.

I see, that makes sense to me, I'll switch to that instead, thanks!

@nodejs-github-bot

This comment has been minimized.

@joyeecheung joyeecheung changed the title inspector: split --cpu-prof-path to --prof-dir and --cpu-prof-name inspector: split --cpu-prof-path to --cpu-prof-dir and --cpu-prof-name Apr 19, 2019
src/env.cc Outdated Show resolved Hide resolved
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@joyeecheung
Copy link
Member Author

If there are no more reviews, I'd like to land this later today.

@joyeecheung joyeecheung added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 22, 2019
@joyeecheung
Copy link
Member Author

Landed in 49d3d11

joyeecheung added a commit that referenced this pull request Apr 22, 2019
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: #27306
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants