Skip to content

perf(actions): debounce runner heartbeat writes and throttle task picks#38281

Open
bircni wants to merge 1 commit into
go-gitea:mainfrom
bircni:perf/actions-runner-poll-nodb
Open

perf(actions): debounce runner heartbeat writes and throttle task picks#38281
bircni wants to merge 1 commit into
go-gitea:mainfrom
bircni:perf/actions-runner-poll-nodb

Conversation

@bircni

@bircni bircni commented Jun 30, 2026

Copy link
Copy Markdown
Member

Split out of #38150, which is being broken into smaller, independently reviewable PRs. This one contains the parts that need no database schema change and can be reviewed/merged on its own.

Two reductions in the DB load generated by many runners polling FetchTask:

1. Debounce runner heartbeat writes
Every poll wrote last_online, and every UpdateTask/UpdateLog wrote last_active — while a runner streams logs that is many writes per second per runner. These are now persisted only when stale enough to actually affect the active/offline status (ShouldPersistLastOnline / ShouldPersistLastActive), using the existing columns.

2. Throttle concurrent task picks
A new in-process semaphore (MAX_CONCURRENT_TASK_PICKS) bounds how many runners run the task-assignment transaction at once, so a fleet polling together cannot stampede the query. Throttled polls retry on their next poll without advancing the runner's tasks version.

No migration — uses existing columns and adds one config option.

Two runner-poll load reductions that need no DB schema changes:

- Debounce last_online/last_active: skip the per-poll and per-UpdateLog
  runner status writes, persisting only when stale enough to affect the
  active/offline status (ShouldPersistLastOnline/ShouldPersistLastActive).
- Bound concurrent task-pick transactions with an in-process semaphore
  (MAX_CONCURRENT_TASK_PICKS) so a fleet polling together can't stampede
  the assignment query; throttled polls retry without advancing the
  runner's tasks version.

Assisted-by: Claude:claude-opus-4-8
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 30, 2026
@bircni bircni requested a review from Zettat123 June 30, 2026 14:33
@bircni bircni added the backport/v1.27 This PR should be backported to Gitea 1.26 label Jun 30, 2026
@github-actions github-actions Bot added the docs-update-needed The document needs to be updated synchronously label Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/v1.27 This PR should be backported to Gitea 1.26 docs-update-needed The document needs to be updated synchronously lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants