fix: run mirror sync git operations at lowest CPU and I/O priority #22
No reviewers
Labels
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
codefloe/forgejo-codefloe!22
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/mirror-sync-low-priority"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Large mirror repos like AUR (71M objects, 147k refs) were consuming ~86% CPU and ~28% RAM during fetch, starving the web server and causing context canceled errors, connection resets, and 3s+ PR merge times. The root cause was twofold:
update_mirrorscron runs every 10 minutes, butnext_update_unixwas only updated on successful sync. Failed or timed-out syncs leftnext_update_unixin the past, causing the mirror to be re-queued every 10 minutes. Even during a long-running sync (~25 min for AUR), the cron would re-queue the mirror since it had already been popped from the unique queue.Changes
Low priority for mirror processes: Add
LowPriorityoption togit.RunOptsthat sets nice 19 (lowest CPU priority) and idle-class I/O scheduling on child git processes. Applied to all mirror pull sync operations (fetch, retry, wiki sync, wiki retry, prune). Linux-only viasyscall.SetpriorityandSYS_IOPRIO_SET; no-op on other platforms.Fix mirror re-queuing during sync: Move
ScheduleNextUpdate()to beforerunSync()so the mirror'snext_update_unixis pushed forward immediately. This prevents the 10-minute cron from re-queuing a mirror that's still running or that just failed. On success,next_update_unixis rescheduled again from completion time.Suppress forced-update noise: Add
--no-show-forced-updatesto mirror fetch commands.Requirements
Requires
CAP_SYS_NICEcapability andsetpriority/ioprio_setsyscalls to be allowed in the systemd unit (deployed via systemd drop-in).f0e8a9c17d4e7a1330ab