Skip to content

Commit f8cec5d

Browse files
committed
coordinator: limit parallelism during chunk assignment
1 parent 9b2b5e0 commit f8cec5d

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

common/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"runtime/debug"
66
)
77

8-
var tag = "v4.7.12"
8+
var tag = "v4.7.13"
99

1010
var commit = func() string {
1111
if info, ok := debug.ReadBuildInfo(); ok {

coordinator/internal/logic/provertask/chunk_prover_task.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ import (
2424
cutils "scroll-tech/coordinator/internal/utils"
2525
)
2626

27+
// Implement global throttle on debug_executionWitness calls.
28+
// This API slows down when there are multiple concurrent calls.
29+
var (
30+
applyUniversalMaxParallelism = 2
31+
witnessSemaphore = make(chan struct{}, applyUniversalMaxParallelism)
32+
)
33+
2734
// ChunkProverTask the chunk prover task
2835
type ChunkProverTask struct {
2936
BaseProverTask
@@ -201,6 +208,17 @@ func (cp *ChunkProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato
201208

202209
if getTaskParameter.Universal {
203210
var metadata []byte
211+
212+
select {
213+
case witnessSemaphore <- struct{}{}:
214+
// Released when Assign returns (defer).
215+
defer func() { <-witnessSemaphore }()
216+
case <-ctx.Done():
217+
log.Warn("context canceled waiting for witness semaphore", "task_id", chunkTask.Hash, "err", ctx.Err())
218+
cp.recoverActiveAttempts(ctx, chunkTask)
219+
return nil, ctx.Err()
220+
}
221+
204222
taskMsg, metadata, err = cp.applyUniversal(taskMsg)
205223
if err != nil {
206224
cp.recoverActiveAttempts(ctx, chunkTask)

0 commit comments

Comments
 (0)