Skip to content

Conversation

crepererum
Copy link
Collaborator

Tokio might preempt tasks at any point so now_or_never might return
None. See https://tokio.rs/blog/2020-04-preemption

We could try to workaround this by using data structures from futures
instead of tokio which to not hook into the tokio cooperative
scheduling. However this has certain drawbacks

  • The cooperative scheduling in tokio is actually not that bad, so we
    should rather work with it instead of against it.
  • The assumption that futures data structures don't participate in
    cooperative scheduling is only because currently they cannot interact
    with the runtime in any way. This might change when Rust's async
    ecosystem evolves so it kinda seems like a non-future-proof
    workaround.

Fixes #102.

While I'm on it I also disallowed async read because it has the same issue as the write counterpart that we've already run into.

@crepererum crepererum requested a review from tustvold February 16, 2022 10:23
@crepererum
Copy link
Collaborator Author

BTW: I haven't been able to reproduce the panic though since the task budget accounting is somewhat nested and cannot be influenced via some direct API.

@crepererum crepererum force-pushed the crepererum/fix_async_issues branch from 36ced5c to 248ad47 Compare February 16, 2022 10:48
Tokio might preempt tasks at any point so `now_or_never` might return
`None`. See https://tokio.rs/blog/2020-04-preemption

We could try to workaround this by using data structures from `futures`
instead of `tokio` which to not hook into the tokio cooperative
scheduling. However this has certain drawbacks

- The cooperative scheduling in tokio is actually not that bad, so we
  should rather work with it instead of against it.
- The assumption that `futures` data structures don't participate in
  cooperative scheduling is only because currently they cannot interact
  with the runtime in any way. This might change when Rust's async
  ecosystem evolves so it kinda seems like a non-future-proof
  workaround.

Fixes #102.
@crepererum crepererum force-pushed the crepererum/fix_async_issues branch from 248ad47 to 37bed03 Compare February 16, 2022 10:50
@crepererum crepererum added the automerge Instruct kodiak to merge the PR label Feb 16, 2022
@kodiakhq kodiakhq bot merged commit 15f424f into main Feb 16, 2022
@crepererum crepererum deleted the crepererum/fix_async_issues branch February 16, 2022 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Instruct kodiak to merge the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic: just flushed
2 participants