-
Notifications
You must be signed in to change notification settings - Fork 78
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
Make --perf-basic-prof toggleable #150
Comments
Current implementation is available here if anyone is interested: nodejs/node@v6.12.3...mmarchini:v6.12.3-perf-basic-prof-toggling |
Talking to @hashseed during the break he suggested that we could expose a public API to capture code events, which would allow userland modules to deal with those code events as necessary (for example, we could have a userland module capable of generating the same
The suggested approach so far is to (somehow) add a "fake" frame to the stack which points to a JIT-function with the purpose of keeping track of those interpreted function calls. This would essentially restore the previous functionality to Linux perf and any other stack recorder (DTrace, eBPF profile, etc.), so it's also platform-agnostic. The end result would look like this: I'll work on a proof-of-concept version for this. @hashseed raised some concerns that this approach may bring a considerable overhead, but once we have a proof-of-concept we can optimize it. |
CodeEventListener is an internal interface that we use to implement various backends for profiling implementations internally. It does make sense to expose this in the V8 API and move backends to node modules and therefore shift the responsibility for maintenance. My concern here is that code events are fairly low-level and the data we want to pass through it may change as we change the way V8 implements code objects. That would cause the ABI to change. |
I think we can come up with some higher-level API/format. For instance, we only need three values to create a proper |
That might be a good idea. Can you maybe collect data to design this API? |
I'll look into it. |
In addition to function name, please include function url as well. Historically V8 was designed to not care about js files too much, but for Node.js use-case the filename is quite important. |
Good point. In CodeEventListener, the filename is extracted from the script, which is referenced by the shared function info. Obviously we do not really want to expose shared function infos this way, so we'd have to extract this information before passing through the API. |
Makes sense. I'll look into the SharedFunction class to see if there are other values we could pass through the API. Maybe we could rename this issue to something like "Cross-platform call stack introspection"? |
For the record: during the discussion about profiling at the Summit we mentioned that maybe in the future we could have a VM independent API to collect code-creation events. We also talked about creating a userland module for Linux perf support once V8 provides this API, and transfer that to the foundation once it's mature. cc/ @mhdawson @hashseed |
Roadmap:
P.S.: Roadmap was moved to #148 |
By the way: we usually don't create such a module inside the foundation from scratch - instead we create them in other namespaces and iterate on them, then transfer them into the foundation when it's mature/ready. |
Updated my comment, thanks for pointing this out @joyeecheung |
I collected data from several profilers to understand what we need for a public API for CodeEventListener. Here's a list of external profilers I investigated:
I also got some data from several npm packages and tutorials using those profilers or the data collected by them:
Except for xperf, all other profilers have at least one tutorial or npm package using Based on those new findings, I think we could either keep If we decide to keep If we decide to go with the CodeEventListener's public API approach, it should be able to collect code objects created before the listener starts to collect data. Here's the minimal public API needed to provide the same information available today on function start addressFirst address for the instructions of this function/builtin function sizeSize (in bytes) of this function/builtin function nameName of this function/builtin function scriptThe script where this JS function was declared. This value is only relevant for JIT/Interpreted functions and will be empty for builtins. function script line & columnThe line and column on the script where this JS function was declared. This value is only relevant for JIT/Interpreted functions and will be empty for builtins. |
Any plans about inlined functions in optimized code? |
A few questions to make sure I understand things here. Sorry if I'm being dense.
Thanks, Mike |
@hashseed haven't thought about that yet. Probably I'll take a look at it after the interpreted frames issue is addressed. |
I see these two as separate (but complementary) issues. The "fake stack frames" proposal is to fix the problem we have today with V8 which makes interpreted functions undistinguishable in the call stack since they all are executed through The second issue is "how" V8 can provide necessary information to allow external profilers to resolve unknown symbols (JIT code, Builtins, etc.). Today this is possible with That being said, it's worth noting that
I don't have opinions on this yet, but
I think the answer to the first question also answered this one. If not please let me know so I can elaborate a little more. |
Thanks @mmarchini. |
should this remain open? [ I am trying to chase dormant issues to closure ] |
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made. |
This can be implemented in userland today via a new API, so closing |
@mmarchini I'm curious to which new API you are refering to ? CodeEventListener ? |
Yes (the public API name might be different, I don't remember and I'm on my phone right now), and there's a module to enable/disable Linux perf maps during runtime: |
Closed, but feel free to keep commenting if you have any questions (or feel free to open another issue) |
I'm a bit confused about the resolution of this issue.
|
@RafaelGSS it is not still in progress, this is addressed by https://www.npmjs.com/package/linux-perf. |
Looking at the V8 implementation a bit, is it correct to assume that v8:: CodeEventListener is no longer used/necessary in node? If that's the case I can clean up the V8 internal API |
The public interface of that, v8::CodeEventHandler is used in the previously mentioned linux-perf module, and I'm also using it for my external CPU profiler. |
Goal is to make to enable --perf-basic-prof dynamically at runtime. Need to resolve fact that this is not a fully supported v8 feature.
The text was updated successfully, but these errors were encountered: