Skip to content

Add dispatchers for running actors on separate carrier pools - #12

Merged
yogthos merged 2 commits into
mainfrom
feat/dispatchers
Oct 11, 2026
Merged

yogthos merged 2 commits into
mainfrom
feat/dispatchers

Conversation

@yogthos

@yogthos yogthos commented Oct 11, 2026

Copy link
Copy Markdown
Member

An actor that makes a blocking foreign call (a C database driver, say) pins its carrier, and every actor placed on that carrier waits until the call returns. Fibers can't migrate, so the only fix is to keep that work on carriers of its own. This adds Akka-style dispatchers on top of jolt's new fiber pools:

(disp/define! :db {:size 8})
(act/spawn query-loop {:dispatcher :db})
(gs/start (->Repo) {:dispatcher :db})

:default is jolt's pool, and :blocking (16 carriers, like Akka's default-blocking-io-dispatcher) is predefined. A pool starts on first use and can be redefined until then. Children don't inherit the dispatcher. An unknown dispatcher is a badarg and spawns nothing. shutdown! refuses new actors and lets running ones finish, and a hibernating actor whose dispatcher went away wakes on :default.

Depends on jolt-lang/jolt#1307. CI runs against jolt's nightly build, so it will fail until that PR is merged and the nightly is rebuilt. Locally the full suite passes against that branch (370 tests), including a test where a usleep FFI call pins one dispatcher while another keeps running.

An actor stuck in a blocking foreign call pins its carrier, and every
actor placed on that carrier waits with it. A dispatcher is a named jolt
fiber pool, as Akka's dispatchers are thread pools: spawn, gen_server,
gen_statem and gen_event take :dispatcher, and process-info reports it.
:default is jolt's pool and :blocking has 16 carriers; define! adds more,
and their carriers start on first use.

The actor keeps its pool so a hibernating actor wakes on it, or on
:default if the dispatcher was shut down in the meantime. Needs jolt with
jolt.fibers/pool (jolt-lang/jolt#1307).
The nightly pre-release hasn't been rebuilt since before fiber pools
landed, so CI was getting a jolt without jolt.fibers/pool. 0.8.21 is the
first release with both fiber kills and pools.
@yogthos
yogthos merged commit 0037a1c into main Oct 11, 2026
2 checks passed
@yogthos
yogthos deleted the feat/dispatchers branch October 11, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant