Repository navigation
Add fiber pools besides the default carrier pool - #1307
Merged
Merged
Conversation
A fiber is pinned to its carrier for life, so a fiber stuck in a blocking
foreign call strands everything queued on its carrier, and there was only
the one pool to put it in. jolt.fibers/pool starts a separate set of
carriers, and (spawn f {:pool p}) places a fiber on one of them. Parks,
resumes, interrupts and kills already go through the fiber's own carrier,
so they work across pools unchanged; the default pool's paths are not
touched.
shutdown! refuses new spawns but each carrier keeps running until the
fibers placed on it have finished, parked ones included. That count lives
on the carrier and is lowered by a monitor on each pool fiber.
The record is jolt-pool rather than jolt-fiber-pool because the latter's
mu accessor would shadow the existing jolt-fiber-pool-mu.
A pool made before the first default spawn ran on the default quantum regardless of *fiber-preempt-ticks*.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fibers are pinned to their carrier for life, so a fiber in a blocking foreign call strands every fiber queued behind it, and the default pool is the only place to put anything. This adds named pools with their own carriers:
Parks, resumes, interrupt! and kill! already go through the fiber's own carrier record, so they work across pools without changes. The default pool's code paths are unchanged apart from spawn being split into pick + spawn-on.
shutdown! refuses new spawns, and each carrier exits only once the fibers placed on it have finished, parked ones included. The live count sits on the carrier under its mu, raised at spawn and lowered by a fiber monitor, so default fibers don't pay for it.
This is for ensemble's Akka-style dispatchers (jlt-commons/ensemble#12).
Tested with the new test/chez/jolt-fiber-pools-test.clj (wired into smoke.sh), which includes a usleep FFI call pinning one pool's carrier while another pool keeps running, plus
make fibers, manifestcheck, lockcheck and parkcheck.