Skip to content

feat: add --sleep-between-batch flag to prevent build storms (#481)#620

Open
kimjune01 wants to merge 4 commits into
lindell:masterfrom
kimjune01:feature/sleep-between-batches
Open

feat: add --sleep-between-batch flag to prevent build storms (#481)#620
kimjune01 wants to merge 4 commits into
lindell:masterfrom
kimjune01:feature/sleep-between-batches

Conversation

@kimjune01
Copy link
Copy Markdown

@kimjune01 kimjune01 commented May 12, 2026

Summary

  • Add --sleep-between-batch flag (e.g. --sleep-between-batch 30s) that inserts a configurable delay between concurrent batches
  • When the flag is not set (default 0), the existing semaphore-based concurrency behavior is unchanged
  • When set, runInParallel switches to batch mode: process --concurrent repos, wait for them to finish, sleep, then start the next batch

This prevents CI/CD build storms when multi-gitter pushes to many repos at once.

Fixes #481

Test plan

  • go test ./... all green
  • go vet clean, race detector clean
  • 4 new tests: no-sleep path, with-sleep timing, single-batch (no sleep triggered), multiple-batch ordering
  • All existing call sites updated (Printer.Print passes 0 for sleep duration)

Failing tests before / Passing tests after / How the tests ran

Sweep attestation 5e95dce4e609 — see the receipts footer below.

kimjune01 added 4 commits May 11, 2026 20:32
Implements a sleep duration between concurrent batches to prevent
overwhelming CI systems when creating multiple PRs at once.

- Add --sleep-between-batch flag accepting duration (e.g., 30s, 1m)
- Modify runInParallel to wait for batch completion before sleeping
- Add comprehensive tests for batch sleep behavior
- Default is 0 (no sleep) to preserve existing behavior

Fixes lindell#481
The previous implementation had a critical bug: it reset the WaitGroup
between batches while goroutines might still be running. This would
cause a panic when those goroutines called Done() on the replaced WaitGroup.

New approach:
- Use explicit batch loops instead of modulo arithmetic
- Each batch has its own WaitGroup that waits for completion
- Fast path (no sleep) uses simple semaphore pattern
- Slow path (with sleep) explicitly batches and waits between them

This ensures no goroutine holds a stale WaitGroup reference.
Remove unnecessary whitespace changes that create diff noise
against the existing struct literal style.
The previous alignment fix commit didn't actually restore the original
spacing. This aligns Labels and CloneDir back to the surrounding field
group width.
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.

Feature request: sleep between concurrent groups

1 participant