llogiq / flame

An intrusive flamegraph profiling tool for rust.
Apache License 2.0
694 stars 30 forks source link

how to get data from multiple threads? #11

Closed llogiq closed 7 years ago

llogiq commented 8 years ago

Currently, a thread-local library is used to collect frames. However, this fails when using multiple threads; the report will only ever contain frames for the thread that started the reporting. So how to report for multiple threads?

I think using a thread local library for collection is the only viable choice (otherwise we'd synchronize cores and thus destroy the performance we intend to measure). Using this for multiple threads would probably require some kind of global library registry (where each thread local would need to be registered on construction, and would also require moving out of the thread on drop). Also we'd need a way to display data from multiple threads without thoroughly confusing users.

TyOverby commented 8 years ago

Yep, that's a good summary. I have plans (and something of an implementation) for the data visualization aspect, but haven't really thought about an implementation yet. Particularly, I don't want to incur any costs for any threads that don't use flame.

I'll do some prototypes when I get the time.

TyOverby commented 7 years ago

There is a threads() method that has been available for a while!