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

Enable Vtune profiling support for JavaScript to provide source code level profiling in Nodejs #3688

Closed
cdai2 opened this issue Nov 6, 2015 · 6 comments
Labels
feature request Issues that request new features to be added to Node.js.

Comments

@cdai2
Copy link
Contributor

cdai2 commented Nov 6, 2015

When debugging Nodejs application, it's very important and usefull that the developer can get the
JavaScript Source code line level profiling information. For example, which sentence of the JavaScript
source code is the most hot position, which sentence leads to cache miss etc. All other profiling tools
such as perf on linux system and the build-in profiling tools in V8 can profiling the C++ source code if
the symbol information is available. But for the the dynamic JITTed JavaScript code , they can not
provided such detailed Source Code Level profiling information.

V8 Javascript engine contains a component which can enable the JavaScript source code
level profiling for the powerful Intel Vtune Amplifier. And this functionality is already enabled by V8
embedder such as chrome and D8 shell. The basic idea is registering the code event handler in
Nodejs for V8. Then Vtune profiling tool will be used to do profiling when running NodeJS.

This functionality will be switched on /off by one runtime flag. And it will be enabled when developer
profiling / optimizing the applications. So it will not lead to any performance impact or correctness issue when running applications under offical senarios.

@cdai2 cdai2 changed the title Enable Vtune profiling support for JavaScript in Nodejs Enable Vtune profiling support for JavaScript to provide source code level profiling in Nodejs Nov 6, 2015
@mscdex mscdex added the feature request Issues that request new features to be added to Node.js. label Nov 6, 2015
@Fishrock123
Copy link
Contributor

All other profiling tools
such as perf on linux system and the build-in profiling tools in V8 can profiling the C++ source code if
the symbol information is available. But for the the dynamic JITTed JavaScript code , they can not
provided such detailed Source Code Level profiling information.

Actually both can be made to work with the JS code.

I forget how to do it for perf, but the built-in v8-prof tools do it automatically. See https://github.com/nodejs/new.nodejs.org/blob/master/locale/en/docs/guides/simple-profiling.md for how to run the v8-prof tools.

@Fishrock123
Copy link
Contributor

This functionality will be switched on /off by one runtime flag. And it will be enabled when developer
profiling / optimizing the applications. So it will not lead to any performance impact or correctness issue when running applications under offical senarios.

Doesn't --prof or --perf_basic_prof already do this?

@bnoordhuis
Copy link
Member

Reasons why VTune is unlikely to get enabled by default:

  1. It depends on external libraries that you need to download from intel.com.
  2. The VTune integration in V8 is GPL licensed. It's a contamination hazard / headache that's extremely unlikely we'd ship in release binaries. (EDIT: It's probably dual licensed. Point 1 still stands though.)

A compile-time option for the people that build from source is probably acceptable, pull requests welcome. I'll close the issue.

@cdai2
Copy link
Contributor Author

cdai2 commented Nov 12, 2015

Hello.
Thank you very much for your comments.
the v8-prof tools, perf tool or --prof or --perf_basic_prof can only provide the function level profiling
information or assembly code level profiling information. For example, it can show how many CPU
times is executed by one function or one assembly code. They cannot provided the profiling
information for one JavaScript sentence. The user does not know which block / sentence is the
root cause.
The attached picture show the example of one profiling result. The hot information of JavaScript sentence and the corresponding assembly code is shown.

I created the pull request #3785 for code review. This feature is a compile-time option according
to bnoordhuis's comments. Thanks

If this patch is landed, I will upload one guide document to describe how to use this feature.

vtune_profiling_javascript_in_nodejs

@dlsniper
Copy link

dlsniper commented Sep 4, 2016

@cdai2 any chance you could link the guide document you mention on how to use this? Thank you!

@cdai2
Copy link
Contributor Author

cdai2 commented Sep 5, 2016

@dlsniper I will add the guide document tomorrow. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js.
Projects
None yet
Development

No branches or pull requests

5 participants