Skip to content

Conversation

@akarnokd
Copy link
Member

This is an alternative to #3937 to capture worker creation sites for computation, io and newThread schedulers.

@akarnokd akarnokd force-pushed the WorkerCreationStacktrace branch from 317824d to c78f3bc Compare May 25, 2016 22:59
* the License.
*/

package rx.internal.schedulers;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to public rx.schedulers and mark as @Experimental?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to expose this, there is the Schedulers.setWorkerTracking. Plus, this way it can be an enum.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, got it.

@artem-zinnatullin
Copy link
Contributor

I see potential problem with this solution: if I jump between threads in the Rx chain it looks like I'll loose stacktrace of subscribe() call.

Observable
  .just(value)
  .observeOn(scheduler1)
  .map(funcA())
  .observeOn(scheduler2)
  .map(funcB())
  .subscribe()

If exception happens in map(funcB()), we will have stacktrace pointing to observeOn(scheduler2), not to observeOn(scheduler1).

Looks like we need to have ThreadLocal<Throwable> and use it's value if it exists in createWorker() to keep stacktrace while jumping between threads.

@akarnokd
Copy link
Member Author

What you are describing is value-origin tracking, not what this and #3937: if a scheduled task crashes, show where the worker has been created, possibly pointing to the assembly site of the sequence.

@artem-zinnatullin
Copy link
Contributor

Then this solution won't cover major percentage of cases when chain jumps between threads and then unexpected exception happens.

For now I vote for keeping initial stacktrace through threads, so 👎, sorry.

@akarnokd
Copy link
Member Author

If exception happens in map(funcB()), we will have stacktrace pointing to observeOn(scheduler2), not to observeOn(scheduler1).

The scheduler2 site is only reported if funcB crashes fatally, which is detected only on the scheduler2's thread. Why would it have to report scheduler1?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants