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

Add support for next node.js stable version: 0.12 #66

Open
c4milo opened this issue Sep 2, 2014 · 16 comments
Open

Add support for next node.js stable version: 0.12 #66

c4milo opened this issue Sep 2, 2014 · 16 comments

Comments

@c4milo
Copy link
Owner

c4milo commented Sep 2, 2014

No description provided.

@vvo
Copy link

vvo commented Sep 3, 2014

Yes! :-)

@petehunt
Copy link

+1

@c4milo
Copy link
Owner Author

c4milo commented Jan 12, 2015

@vvo, @petehunt which version are you guys using?

@vvo
Copy link

vvo commented Jan 12, 2015

Still 0.10.35 :-)

@pauliusuza
Copy link

+1, and io.js please

@metamatt
Copy link
Collaborator

I just sent #79 which ports this code to use nan. I see that as a necessary but not sufficient step to getting this working with current V8/node.js/io.js versions. (Not sufficient because the profiler API itself, which I don't know anything about and haven't looked into yet, has also changed and nan doesn't abstract that. So my PR uses nan where possible, but there are still a bunch of compile errors under 0.12.0 for missing profiler API methods.)

Here are the remaining errors when compiling #79 with node 0.12.0. (It compiles fine under node 0.10.x.)

@c4milo
Copy link
Owner Author

c4milo commented Feb 27, 2015

@metamatt great, this is a good start. I will look in detail tomorrow. Thank you!

@metamatt
Copy link
Collaborator

Here's my take on the remaining problems after the nan patch, from looking at deps/v8/include/v8-profiler.h in node 0.10.x (V8 3.14) and node 0.12.0 (V8 3.28):

Changed name (easy):

  • interesting methods of HeapProfiler added “Heap” to the method name (GetSnapshot -> GetHeapSnapshot, etc)
  • HeapProfiler::GetSnapshotsCount became GetSnapshotCount
  • HeapProfiler::TakeHeapSnapshot (was TakeSnapshot) no longer takes “type” argument (and no longer has kFull constant to specify as “type” argument), has new global_object_name_resolver argument but it’s optional so hopefully not supplying it works out ok)

Became relative to Isolate instance (medium, just plumbing? But I don’t know where to plumb the Isolate instance in):

  • the interesting methods of CpuProfiler (StartProfiling, StopProfiling, DeleteAllProfiles) and HeapProfiler (TakeHeapSnapshot, DeleteAllHeapSnapshots, GetHeapSnapshot, FindHeapSnapshot, GetSnapshotCount) were static methods, and are now instance methods, require the object instance which you can get from the Isolate (GetCpuProfiler(), GetHeapProfiler())

Removed with no obvious replacement (hard, if things need them? easy, if that means they won’t be called any more?):

  • CpuProfile class has no getUid or GetBottomRoot (no mention of bottom-up profiling anywhere)
  • CpuProfiler has no GetProfilesCount, GetProfile or FindProfile (no access to existing CpuProfile objects via CpuProfiler? Only way to get CpuProfile object is at time of acquiring profile, via CpuProfiler::StopProfiling?)
  • CpuProfileNode has no GetTotalTime, GetSelfTime, GetTotalSamplesCount, GetSelfSamplesCount

@c4milo
Copy link
Owner Author

c4milo commented Mar 11, 2015

Very useful information @metamatt. It seems to me we will have to dig into Chromium's code as well, to see how they are currently using v8's profiler API, specifically for the Chrome Devtools backend. A lot has changed since this project was originally written. For instance, Isolates weren't really a thing when this project started.

Regarding your hard points:

  • CpuProfile class has no getUid or GetBottomRoot (no mention of bottom-up profiling anywhere)

Was removed here: v8/v8@acf9edb#diff-f2be5615de603fba6f3f54c2c346f58d

CpuProfiler has no GetProfilesCount, GetProfile or FindProfile (no access to existing CpuProfile objects via CpuProfiler? Only way to get CpuProfile object is at time of acquiring profile, via CpuProfiler::StopProfiling?)

It seems you can get the CpuProfiler from the current Isolate instance, and the actual profile output once you stop profiling, exactly like you described it. Disregard if you already know, you get the current isolate like so: Isolate* isolate = Isolate::GetCurrent();

v8/v8@0da5cad#diff-f2be5615de603fba6f3f54c2c346f58d

CpuProfileNode has no GetTotalTime, GetSelfTime, GetTotalSamplesCount, GetSelfSamplesCount

These were deprecated here:

@metamatt
Copy link
Collaborator

For the removed methods, I'm hoping a newer version of the frontend might not want to call these methods on the backend. For the Isolate instance, we can get the current Isolate and we can supply it to the V8 profiler API, as long as that's the correct one to supply; I'm wondering if we ever need to deal with a case where there's more than one and we have to keep track of multiple instances.

@c4milo
Copy link
Owner Author

c4milo commented Mar 11, 2015

For the removed methods, I'm hoping a newer version of the frontend might not want to call these methods on the backend.

It seems that's the main reason they took them out.

For the Isolate instance, we can get the current Isolate and we can supply it to the V8 profiler API, as long as that's the correct one to supply; I'm wondering if we ever need to deal with a case where there's more than one and we have to keep track of multiple instances.

No need to deal with more than one as far as I know. If people want to profile isolated processes they will have to import node-webkit-agent in those processes too.

@metamatt
Copy link
Collaborator

@c4milo do you want to call this fixed for 0.12 and publish a new version to npm?

@c4milo
Copy link
Owner Author

c4milo commented Jun 16, 2015

@metamatt is the CPU profiler still working or we will be loosing it for Node 0.12.x?

@c4milo
Copy link
Owner Author

c4milo commented Jun 16, 2015

@metamatt the other thing I haven't tested is whether the changes are backwards compatible with previous versions of node.

@metamatt
Copy link
Collaborator

CPU profiler is not working, but I don't see how to get it to work. If you can figure it out, great; otherwise I think heap profiler is better than nothing.

The changes I made are backwards compatible with node 0.10 (well, they work for me but if you have a better way to verify that, please do!).

@c4milo
Copy link
Owner Author

c4milo commented Jun 16, 2015

CPU profiler is not working, but I don't see how to get it to work. If you can figure it out, great; otherwise I think heap profiler is better than nothing.

Agreed. I'm going to give it another round of tests and release a new version as soon as I can. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants