8000 Release 0.2.2: parallel task calls, named task limits, late lease renewal warning by arminhammer · Pull Request #43 · arminhammer/jackdaw · GitHub
[go: up one dir, main page]

Skip to content

Release 0.2.2: parallel task calls, named task limits, late lease renewal warning - #43

Merged
arminhammer merged 3 commits into
mainfrom
task-limits
Nov 2, 2026
Merged

arminhammer merged 3 commits into
mainfrom
task-limits

Conversation

@arminhammer
@arminhammer arminhammer commented Nov 2, 2026 •
Copy link
Copy Markdown
Owner

Summary

Batch jobs written as one workflow with many CPU-heavy calls used one core: concurrent calls of an instance shared the instance's tokio task. This PR makes those calls run in parallel, adds a way to cap them, and reports the one hazard that parallel async work makes easier to hit.

  • Parallel async task calls. Each call of an async task runs as a tokio task of its own (NativeTask::invoke). futures::try_join!, join_all and ctx.for_each(..).concurrency(n) now run in parallel on the runtime's threads. This also covers a YAML fork whose branches call Rust tasks. Dropping the call's future still aborts it. Replay is unaffected, since results are journaled by sequence number.
  • Named limits (no new task type, no new dependency):
    • Naming one: #[task(limit = "name")] works on async tasks, blocking tasks and #[tasks] methods, and several tasks can share a limit.
    • Defining one: EngineBuilder::limit(name, permits) defines it for every instance the engine runs. EngineBuilder::blocking_limit(n) covers blocking tasks that name no limit; without it they are not limited, as before.
    • Waiting: a call waits for a semaphore permit, in arrival order, without holding a thread. A blocking call moves its permit into the closure, so a cancelled workflow can't push the count over the limit.
    • YAML: a YAML call: of a Rust task waits for the task's limit too.
    • Build errors: build() rejects a limit the engine doesn't define, and one with 0 permits.
    • Timeouts: the heartbeat timeout starts once the call has its permit. A step timeout includes the wait, because its deadline is durable and fixed at step start.
    • Metrics: with metrics, the jackdaw_task_limit_waiting gauge counts the waiting calls per limit.
  • Late lease renewal warning. If the lease loop wakes more than a quarter of the TTL late, the runtime's threads were busy elsewhere. The engine then logs lease renewal ran late, with the delay, and suggests #[task(blocking)]. Only the loop's sleep is timed, so a slow store does not trigger it.

No rayon: spawn_blocking plus semaphores covers the cap, and tasks can still use rayon inside.

Release

Bumps the workspace to 0.2.2 (Cargo.toml and its =0.2.2 pins, Cargo.lock, the Dockerfile label, and CHANGELOG.md dated 2026-11-02). Merging triggers release-on-merge: binaries, the Docker image, the v0.2.2 GitHub release and the crates. just publish- 8000 dry-run passes. If this merges after 2026-11-02, update the changelog date first.

Tests

The specs were written before the implementation and failed first:

  • tasks/task_limits.feature, 11 scenarios:
    • Two calls only complete if they run on different threads, tested with try_join! and with for_each(..).concurrency(2).
    • Limits cap calls across workflows.
    • A limit is shared between a free-function task and a #[tasks] method.
    • The blocking limit applies, and a task's own limit overrides it.
    • Without a limit, blocking calls are not capped.
    • Build errors.
    • A queued call isn't charged against its heartbeat timeout.
    • A YAML fork respects the limit.
  • operations/lease_renewal.feature, 2 scenarios, each on a one-thread runtime of its own:
    • an async task blocking the thread produces the warning;
    • a blocking task doesn't.

Results:

  • Specs: all 359 pass on Redb, and the 13 new ones pass on SQLite.
  • Other suites: lib, Rust API, doc, CTK, listener and nested-workflow tests pass.
  • Checks: clippy is clean for all features and for the reduced feature sets; fmt and the docs build are clean, and the semver check is clean.

🤖 Generated with Claude Code

arminhammer and others added 2 commits November 2, 2026 12:44
- Each async task call runs as a tokio task of its own, so the calls a
  workflow makes at once (try_join!, join_all, for_each(..).concurrency(n))
  run in parallel instead of sharing the workflow's thread. Dropping the
  call's future still stops it.
- Named limits: #[task(limit = "name")] on async, blocking and #[tasks]
  method tasks; EngineBuilder::limit(name, permits) defines one for the
  whole engine, and EngineBuilder::blocking_limit(n) covers blocking tasks
  that name none. Calls wait for a permit in order without holding a
  thread; a blocking call keeps its permit until its thread is done. YAML
  `call:`s of Rust tasks wait too. build() rejects an undefined limit or
  one with no permits. The heartbeat timeout starts once a call has its
  permit. With `metrics`, jackdaw_task_limit_waiting counts the waiters.
- The lease loop warns when it wakes more than a quarter of the lease TTL
  late (the runtime's threads were busy), pointing at blocking code in
  async tasks.

Specs: tasks/task_limits.feature (11 scenarios) and
operations/lease_renewal.feature (2), written before the implementation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@arminhammer arminhammer changed the title Parallel task calls, named task limits, late lease renewal warning Release 0.2.2: parallel task calls, named task limits, late lease renewal warning Nov 2, 2026
@arminhammer
arminhammer merged commit 5af8f87 into main Nov 2, 2026
18 checks passed
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

0