typelevel / typelevel/cats-effect
`executeEmbed` should auto-cede between every step by default
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 2.2k
- Forks
- 576
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 18
Description
Although the test runtime and executeEmbed cannot be used to exercise race conditions, it is still very useful for being able to exercise non-deterministic scheduling of fibers. In fact we can get even closer to simulating parallel execution by randomly interleaving the individuals steps of concurrently running fibers, by configuring the test runtime to auto-cede between every step.
Arguably there is no harm to auto-cede between every step. Because fiber scheduling is entirely random, the fiber that auto-ceded may end up being immediately rescheduled anyway (as if it never ceded at all). So we are not ruling out any possible scenarios, we are only expanding them to include more permutations of the various interleavings between concurrently running fibers.
There are certain bugs which cannot be tested without this, for example:
https://github.com/typelevel/cats-effect/blob/8d8097815594be405af2fcfddb4c9b599a1d04d4/tests/jvm/src/test/scala/cats/effect/kernel/AsyncPlatformSpec.scala#L46-L69
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with tests/jvm/src/test/scala/cats/effect/kernel/AsyncPlatformSpec.scala, especially the linked lines, then trace the executeEmbed test runtime implementation. Confirm the default scheduling behavior and add coverage showing that concurrently running fibers can be interleaved between individual steps by default.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100