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

Improve thread troubleshooting experience #266

Open
gluck opened this issue Aug 19, 2016 · 2 comments
Open

Improve thread troubleshooting experience #266

gluck opened this issue Aug 19, 2016 · 2 comments

Comments

@gluck
Copy link

gluck commented Aug 19, 2016

Rx can create threads in various conditions (NewThreadScheduler, EvenLoopScheduler, ThreadPoolScheduler.ScheduleLongRunning, ConcurrencyAbstractionLayer ...), resulting in any leak being impossible to track down to the cause.

Today with the PlatformEnlightmentProvider one can inject thread factories in some of these places, allowing the user to inject troubleshooting information when threads are created such as:

  • debug log before creating thread
  • propagate thread local data
  • forcing background threads
  • formatting extra info into the thread name, such as:
    • parent thread name
    • current UI view/form/window/scene

(in case the user is repacking Rx, he can include the assembly name as well, very useful to us ! - but I digress)

If you ever troubleshoot an application with a thread leak and 200+ Rx threads all called "Thread-#XX", maybe you know where this request comes from :)

@akarnokd
Copy link
Collaborator

I'm not sure this can be reasonably solved. Schedulers and their backing threads are orthogonal to the flows they service and without injecting context information deeply, there isn't much to be done in general. I usually suggest adding a doOnEach (Do) operator which sets the current thread's name to something contextual to the user that helps identify what was happening when a thread dump is taken later.

@bartdesmet
Copy link
Collaborator

Agreed with @akarnokd on the hard part being correlating scheduler (and thus sometimes thread-related) activity and the higher-level operations being served (i.e. query evaluation). This said, we can likely add minimal support to make diagnostics a little bit easier by virtue of allowing users to have more control over the name of threads created by the library (e.g. parameters on constructors for EventLoopScheduler etc.). I'll have a look into that aspect.

@bartdesmet bartdesmet added this to the Rx 5.0 milestone Sep 29, 2020
@bartdesmet bartdesmet modified the milestones: Rx 5.0, Rx 5.1 Nov 10, 2020
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