Skip to content

cmd/utils: add --exec.serial flag to clamp workers to 1#20853

Merged
mh0lt merged 1 commit intomainfrom
feat/exec-serial-flag
Apr 28, 2026
Merged

cmd/utils: add --exec.serial flag to clamp workers to 1#20853
mh0lt merged 1 commit intomainfrom
feat/exec-serial-flag

Conversation

@mh0lt
Copy link
Copy Markdown
Contributor

@mh0lt mh0lt commented Apr 28, 2026

Summary

Follow-up to #20797. Adds a single-purpose boolean — `--exec.serial` — that forces serial execution by clamping the parallel executor's worker count to 1. Wins over both `--exec.workers` and `EXEC3_WORKERS`.

Why a separate flag rather than just `--exec.workers=1`

  • States intent at the call site ("force serial"), so logs / launch scripts / dashboards read clearly.
  • Can't be accidentally undone by a stale `EXEC3_WORKERS` env var picked up by a test harness or wrapper script.
  • Lets operators do like-for-like baseline comparisons against the parallel executor (A/B perf runs on bal-devnet-3, profiling cold paths) without juggling worker numbers.

Precedence (resolved in `SetEthConfig`)

Flags / env Result
`--exec.serial=true` `workers=1`
`--exec.workers=12 --exec.serial=true` `workers=1` (serial wins)
`--exec.workers=12` `workers=12`
`--exec.serial=false` (default) no override; env var / default applies

Test plan

  • `go test -short ./cmd/utils/...` — `TestExecPerfFlags_OverrideDbg` extended with three new subtests: serial=true clamps, serial=true wins over --exec.workers, serial=false leaves Exec3Workers untouched.
  • `make lint` — 0 issues, twice.
  • `make erigon` — `--help` shows the new flag with the correct usage and default.

Files touched

  • `cmd/utils/flags.go` — flag definition + wiring in SetEthConfig (post --exec.workers so it overrides cleanly).
  • `cmd/utils/flags_test.go` — three new subtests.
  • `node/cli/default_flags.go` — register flag in DefaultFlags.

~35 LOC including tests.

Follow-up to #20797. Adds a single-purpose boolean that forces serial
execution by clamping the parallel executor's worker count to 1 — wins
over both --exec.workers and EXEC3_WORKERS. Cleaner than `--exec.workers=1`
because it states intent ("force serial") at the call site rather than
relying on a magic value, and it can't be accidentally undone by a stale
EXEC3_WORKERS env var that gets re-read by tooling.

Use case: like-for-like baseline comparisons against the parallel executor
(devnet A/B runs, profiling cold paths) where the operator explicitly
wants serial irrespective of any other knob.

Wiring: applied AFTER --exec.workers in SetEthConfig, so:
  --exec.serial=true                          → workers=1
  --exec.workers=12 --exec.serial=true        → workers=1 (serial wins)
  --exec.workers=12                           → workers=12
  --exec.serial=false  (default)              → no override

Test: TestExecPerfFlags_OverrideDbg covers serial-true, serial-vs-workers
precedence, and serial-false-leaves-untouched.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an explicit --exec.serial CLI flag to force serial execution in the parallel executor by clamping worker count to 1, overriding both --exec.workers and EXEC3_WORKERS when enabled.

Changes:

  • Introduce ExecSerialFlag (--exec.serial) and apply it in SetEthConfig to clamp executor workers to 1 when true.
  • Register the new flag in the Erigon binary’s DefaultFlags.
  • Extend TestExecPerfFlags_OverrideDbg with subtests covering serial clamping and precedence over --exec.workers.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
node/cli/default_flags.go Registers --exec.serial alongside other --exec.* perf flags so it shows up in --help and is recognized by the main binary.
cmd/utils/flags.go Defines ExecSerialFlag and enforces precedence in SetEthConfig by clamping worker count to 1 when enabled.
cmd/utils/flags_test.go Adds subtests validating --exec.serial behavior and its override precedence.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/utils/flags_test.go
Comment on lines +209 to +210
// flags are applied in declaration order (workers first, then serial),
// so serial should override workers regardless of CLI argument order.
@mh0lt mh0lt added this pull request to the merge queue Apr 28, 2026
mh0lt added a commit that referenced this pull request Apr 28, 2026
…orkers to 1 (#20863)

Cherry-pick of #20853 to bal-devnet-3. Depends on #20862 (#20797
cherry-pick).

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Merged via the queue into main with commit 5340dd0 Apr 28, 2026
42 checks passed
@mh0lt mh0lt deleted the feat/exec-serial-flag branch April 28, 2026 09:14
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