Skip to content

gitserver: periodically run git gc

Administrator requested to merge cloud/gitserver-gc into main

Created by: flying-robot

This introduces a performGC janitor task to gitserver that will run git gc --auto periodically to clean up any repository garbage, and (hopefully) improve the performance of various operations downstream.

The auto form of GC is actually performed automatically by a number of different git commands, and so is intended to be very fast in the common case. We'll largely rely on its internal heuristics to decide whether to take action, but we have several levers that could be pulled if need be.

The entire thing is gated with an SRC_ENABLE_GC_AUTO environment variable, which currently defaults to true.

@keegancsmith and I also discussed metrics and monitoring, but it's a bigger subject than just GC. So our shared opinion was to focus on the functionality here, and quickly follow up with more comprehensive observability that overlaps with work @arussellsaw has been doing.

TODOs

  • supporting tests
  • chat w/ @keegancsmith re: the scheduling strategy

fixes https://github.com/sourcegraph/sourcegraph/issues/16241

Merge request reports

Loading