VerySleepy / verysleepy

Very Sleepy, a sampling CPU profiler for Windows
http://www.codersnotes.com/sleepy
GNU General Public License v2.0
1.05k stars 103 forks source link

Support for sample filtering by thread #86

Closed aaalexandrov closed 3 years ago

aaalexandrov commented 3 years ago

Implement source thread-aware sample gathering, file format and display in the UI. Add sample filtering by thread. Add symbol per-thread statistics UI. Fixes #70

CyberShadow commented 3 years ago

I can't open old .sleepy files with this change, could you please check? We should support loading old files even when the format for new files changes.

aaalexandrov commented 3 years ago

I did not add compatibility code for opening the old file format files because I saw no compatibility code there for any old versions. There didn't seem to be any infrastructure for that in place, aside from comparing to the current version and aborting in case it's different. I can add loading from 0.90 specifically, but not backwards from there. Out of curiosity, how often does this format change?

CyberShadow commented 3 years ago

I did not add compatibility code for opening the old file format files because I saw no compatibility code there for any old versions.

You're right, my mistake. I thought I remembered some compatibility code, but I guess I was wrong. So, I take that back (though of course, speaking of a separate enhancement, compatibility would be nice if possible).

Out of curiosity, how often does this format change?

Well, the 0.90 version was bumped in 2014...

aaalexandrov commented 3 years ago

I'll do compatibility from 0.90 in the coming days, it should be straightforward enough.

CyberShadow commented 3 years ago

OK, only if you want (my initial statement was based on a bad assumption, and practically speaking, it's easy enough to download an older version to open older files).

Since you're working with threads, maybe looking at #4 would be a better use of your time.

As for this PR, I will try to have a closer look at it and merge it soon.

aaalexandrov commented 3 years ago

I'll see what I can do about sampling newly spawned threads. Is there a better way to detect them than just polling and comparing to the threads we're already tracking?

CyberShadow commented 3 years ago

I believe that a long time ago, @rmitton tried to implement this by making Very Sleepy also work as a debugger, attaching itself to the process. That would allow it to be notified of new threads using CREATE_PROCESS_DEBUG_EVENT.

There is code for this in src/profiler/debugger.cpp, but it was never finished.

See also #20.

CyberShadow commented 3 years ago

Great! Thank you, and I don't have any more suggestions :)

Since I have a good setup for it, I am going to try and massage the git history a bit to ungroup unrelated changes from the big commits and squash changes that are not relevant to the history.

aaalexandrov commented 3 years ago

Thanks, if there's anything I missed, don't hesitate to say. I'll probably do the issue about profiling newly spawned threads at some point, but it'll take me some time.

aaalexandrov commented 3 years ago

It looks great to me, thanks for separating the commits.

CyberShadow commented 3 years ago

Thanks for the very nice contribution :)