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 taking stack snapshots of other threads: The Linux/Android edition #22203

Open
gterzian opened this Issue Nov 15, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@gterzian
Collaborator

gterzian commented Nov 15, 2018

Follow up on #16740

Code in components/background_hang_monitor/sampler.rs(yet to be merged from #21673)

The suspending/resuming of a thread is (perhaps only partly) implemented, and it is mainly accessing the instruction and frame pointers in the registers, as well as perhaps the stack walking, that needs to be (re-)implemented for Linux/Android.

I think target architectures for Linux would be x86_64, and for Android it would be x86 for the emulator, and arm for the devices.

It appears that libc would be the appropriate tool in both cases.

See also the Gecko implementation at https://dxr.mozilla.org/mozilla-central/rev/b0b856065d5b7ad2996f707e6e797d0d72afd803/tools/profiler/core/platform-linux-android.cpp#85

@nikhilm

This comment has been minimized.

nikhilm commented Nov 21, 2018

FWIW, I have a work in progress library (i only made it publicly viewable so i could post this, heh! still needs documentation and so on) for a sampling profiler. https://bitbucket.org/nikhilm/vignette.
It already implements Linux thread suspension and resume, and was actually inspired by the gecko implementation. I work on this really on and off, so I won't be able to fix this issue itself, but feel free to copy the code from https://bitbucket.org/nikhilm/vignette/src/master/src/lib_linux.rs

@gterzian

This comment has been minimized.

Collaborator

gterzian commented Nov 22, 2018

@nikhilm thanks!

I'll restructure the Mac-Os one to use a similar Sampler abstractions and and then we can use your implementation for Linux/Android.

I assume your PosixSemaphore beats what I was trying to do with https://github.com/servo/servo/pull/21673/files#diff-b842b7c119b3715c2ee8e59aa3df11a2R32

Also, your implementation of Sample.collect fills in a gap in the current linux work in progress(I only go the equivalent to work on Mac).

For the yet to be implemented resolving of the frames, we can use backtrace::resolve which will work across platforms...

I'll focus on re-structuring the Mac part, as well as the overall structure, so that it will "fit" better with this, I might try the actual Linux implementation after that, and if anyone else is interested, just let me know...

@gterzian gterzian referenced this issue Nov 22, 2018

Merged

Add background hang monitor #21673

0 of 5 tasks complete

@gterzian gterzian referenced a pull request that will close this issue Dec 3, 2018

Open

[WIP] Add linux sampler #22355

0 of 5 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment