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

Add BlockHound support #3308

Closed
OliverO2 opened this issue Nov 28, 2022 · 2 comments · Fixed by #3316
Closed

Add BlockHound support #3308

OliverO2 opened this issue Nov 28, 2022 · 2 comments · Fixed by #3316
Labels
enhancement ✨ Suggestions for adding new features or improving existing ones.

Comments

@OliverO2
Copy link
Contributor

kotlinx-coroutines-debug supports a BlockHound integration. However, Kotest currently does not.

Using Kotest in conjunction with BlockHound is usually fine. The following issue is an exception. Kotest uses ThreadPoolExecutor by default in FixedThreadCoroutineDispatcherFactory (via Executors.newSingleThreadExecutor().asCoroutineDispatcher()), which briefly blocks for thread queue management:

If that's OK, I could prepare a PR with a BlockHound integration solving the above issue.

@OliverO2 OliverO2 added the enhancement ✨ Suggestions for adding new features or improving existing ones. label Nov 28, 2022
@sksamuel
Copy link
Member

sksamuel commented Dec 5, 2022

Feel free to raise a PR for us to look at. BlockHound seems reactor specific?

@OliverO2
Copy link
Contributor Author

OliverO2 commented Dec 5, 2022

While BlockHound is a reactor project, it provides the same benefits with coroutines when used with the kotlinx-coroutines-debug module:

It reports blocking calls from threads that are part of the coroutine thread pool and currently execute a CPU-bound coroutine computation. It helps to detect thread-blocking early, e.g. when calling a blocking I/O library function. In a case like this, one can decide whether to

  • replace the call with a non-blocking one (using a coroutine-aware library), or
  • schedule the calling coroutine to run on a separate I/O thread, or
  • add an exception if the blocking is harmless.

I'll prepare a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ Suggestions for adding new features or improving existing ones.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants