Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

perf(ci): tune golangci-lint GC to cut CPU and cap RSS (#21398)

Danny Xu127de2afbd26
diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml
index 5450d00055..2967cece12 100644
--- a/.github/workflows/golangci-lint.yml
+++ b/.github/workflows/golangci-lint.yml
@@ -50,4 +50,12 @@ jobs:
exit 1
fi
- name: golangci-lint
+ env:
+ # Go's default GOGC=100 collects every time a ~5 GB live heap doubles, which
+ # is the wrong policy for a batch run. Collecting near a target instead is
+ # cheaper on CPU, wall and peak RSS alike. GOMEMLIMIT is a soft limit over
+ # Go-managed memory, not a guaranteed RSS ceiling, but it holds in practice
+ # here: 10.17 GB peak measured, against 11.05 GB with the default.
+ GOGC: "off"
+ GOMEMLIMIT: 10GiB
run: golangci-lint run --verbose -j 8 --timeout 30m --max-same-issues=30 --allow-parallel-runners
\ No newline at end of file
diff --git a/AGENTS.md b/AGENTS.md
index 6a92ba7d17..5e4cc52d77 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -40,7 +40,7 @@ During iteration, run focused checks for the changed behavior. Before handoff, r
### Go changes
1. Run `gofmt -w` on modified Go files.
-2. Run `golangci-lint run --fix -j 8 --allow-parallel-runners`, then `golangci-lint run -j 8 --allow-parallel-runners` until clean after corrections. Run at repo root without filenames so package context is available. Keep `-j 8`: on a cold cache it trades ~15s of wall time for ~30% less CPU and ~1.5 GB less peak RSS on the shared box.
+2. Run `GOGC=off GOMEMLIMIT=10GiB golangci-lint run --fix -j 8 --allow-parallel-runners`, then the same command without `--fix` until clean after corrections. Run at repo root without filenames so package context is available. Keep the flags: on a cold cache they take the run from ~730 to ~420 CPU-seconds and hold peak RSS near 10 GB, on a box shared with two CI runners.
3. Run tests for changed packages and affected behavior, including required collision or contention coverage.
4. Build: `go build -ldflags "-w -s" -p=16 -o ./bytebase-build/bytebase ./backend/bin/server/main.go`.
5. After dependency changes, run `go mod tidy` and recheck affected code.