-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: sched: Cache worker calls #9737
Conversation
329116a
to
fb3e9a6
Compare
fb3e9a6
to
dee3de9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with two nits looking for comments to make code slightly more clear.
storage/sealer/sched_test.go
Outdated
func (s slowishSelector) Ok(ctx context.Context, task sealtasks.TaskType, spt abi.RegisteredSealProof, a SchedWorker) (bool, bool, error) { | ||
_, _ = a.Paths(ctx) | ||
_, _ = a.TaskTypes(ctx) | ||
return bool(s), false, nil | ||
} | ||
|
||
func (s slowishSelector) Cmp(ctx context.Context, task sealtasks.TaskType, a, b *WorkerHandle) (bool, error) { | ||
time.Sleep(100 * time.Microsecond) | ||
func (s slowishSelector) Cmp(ctx context.Context, task sealtasks.TaskType, a, b SchedWorker) (bool, error) { | ||
_, _ = a.Paths(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you leave a comment here as to why you're ignoring the outputs of the function calls?
partDone := metrics.Timer(sh.mctx, metrics.SchedAssignerCandidatesDuration) | ||
defer func() { | ||
partDone() | ||
}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you leave a comment here saying that this defer is meant to call the latest value of partDone
in case we error out somewhere.
dee3de9
to
2fd7550
Compare
2fd7550
to
1597e85
Compare
Related Issues
Based on on #9738
Proposed Changes
I've re-read the scheduler code today, and realized that all calls to workers in the scheduling loop are perfectly cachable. This PR adds some caching in the scheduling loop, theoretically reducing the number of workers calls in a scheduling cycle from
tasksToSchedule*candidateOpenWindows
tounique(candidateOpenWindows.Worker)
Additional Info
Benchmark on 400 deep queue with 200 workers (tldr ~700x faster when network roundtrips are ~100us)
Before:
After:
Checklist
Before you mark the PR ready for review, please make sure that:
<PR type>: <area>: <change being made>
fix: mempool: Introduce a cache for valid signatures
PR type
: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, testarea
, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps