Skip to content

Stop rescanning the job backlog when picking the next tier2 job - #923

Merged
sduchesneau merged 4 commits into
developfrom
scheduler-nextjob-cursor
Sep 3, 2026
Merged

Stop rescanning the job backlog when picking the next tier2 job#923
sduchesneau merged 4 commits into
developfrom
scheduler-nextjob-cursor

Conversation

@sduchesneau

@sduchesneau sduchesneau commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Picking the next tier2 job walked every segment between the squasher and the job frontier on every call, re-checking dependencies that could not have changed: every stage above 0 holds Pending units across that whole backlog, each waiting on the stage below to squash the previous segment. The scheduler now keeps, per stage, the lowest segment that may be Pending and the completed prefix, and a stage can only run at or below the prefix of the stages under it, so a call visits one segment per stage plus the shadow window. Every transition back to Pending rewinds the cursors, so a map output found missing is still re-scheduled. Job order is unchanged.

Measured, 3 stages, 4 workers, squasher 3x slower than the jobs, whole run:

segments before after
1000 19.7 ms 0.34 ms
8000 1181 ms 2.73 ms

Before grew 3.9x per doubling of the range, after 2x. Per call at 8000 segments: 27 µs to 62 ns.

In perspective, with 1000-block segments: at 400M blocks (Solana, Arbitrum) a call cost about 3 ms with 3 stages, about 6 ms with 5, and the scheduler loop makes 5 to 9 calls per job. That is a few percent of one core on a normal full-history run, and only became the bottleneck in noop or store-only mode with fast jobs and many workers, where the loop saturated while tier2 waited. In production mode the walker already bounds the backlog to a few hundred segments, so nothing changes there.

The scan cursor stopped at the squasher because every higher stage
holds pending units from there to the job frontier, all waiting on the
lower stage's previous segment, so each call walked that backlog again.
Per-stage cursors now give the lowest pending segment and the completed
prefix, and a stage can only run at or below the prefix of the stages
under it, so a call visits one segment per stage plus the shadow window.
8000 segments with a slow squasher: 1.18 s to 2.7 ms, growth now linear.
Base automatically changed from execout-prefetch to develop September 3, 2026 16:10
@dfuse-bot
dfuse-bot requested a review from billettc September 3, 2026 16:11
@dfuse-bot

dfuse-bot commented Sep 3, 2026

Copy link
Copy Markdown

🔍 Vulnerabilities of ghcr.io/streamingfast/substreams:30d9238

📦 Image Reference ghcr.io/streamingfast/substreams:30d9238
digestsha256:1cf74d2e8b1264eca93f5525c937239eaf1f8a79e0deee566904213cce3422fd
vulnerabilitiescritical: 0 high: 0 medium: 0 low: 0
platformlinux/amd64
size124 MB
packages380
📦 Base Image ubuntu:24.04
also known as
  • c1ca75be10a22ea09ff0b7bbe8b82ee03553a4f9b795030ee2ec921e42418fc8
  • noble
  • noble-20260810
digestsha256:1e0a86e57d247923571b75e0aaf48a1449cf8c543d51fb3e07a4a7d7bfa79316
vulnerabilitiescritical: 0 high: 0 medium: 24 low: 11

@sduchesneau
sduchesneau merged commit 4035f21 into develop Sep 3, 2026
8 checks passed
@sduchesneau
sduchesneau deleted the scheduler-nextjob-cursor branch September 3, 2026 16:25
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.

3 participants