Skip to content

Commit 0cc2854

Browse files
committed
snapshot-agent: move the GPU-CR sweeper to the utils package
backends/gc.go -> utils/gpu-cr_utils.go (tests likewise), StartGC -> StartGPUCRSweeper. The sweeper is GPU-CR hygiene shared by any GPU-CR-driven backend, not backend logic itself, so it lives with the other node-level helpers.
1 parent 9052a70 commit 0cc2854

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

cmd/snapshot-agent/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/llm-d-incubation/llm-d-rl-time-slicing/pkg/snapshot-agent/backends"
2727
"github.com/llm-d-incubation/llm-d-rl-time-slicing/pkg/snapshot-agent/features"
2828
"github.com/llm-d-incubation/llm-d-rl-time-slicing/pkg/snapshot-agent/server"
29+
"github.com/llm-d-incubation/llm-d-rl-time-slicing/pkg/snapshot-agent/utils"
2930
)
3031

3132
func main() {
@@ -87,8 +88,7 @@ func main() {
8788
}
8889

8990
// GPU-CR housekeeping runs only when the shared checkpoint dir is
90-
// configured (the Helm chart sets EXPORT_FILE_PATH iff a GPU-CR-driven
91-
// backend is enabled), keeping CUDA/app-only deployments untouched.
91+
// configured, keeping CUDA/app-only deployments untouched.
9292
if ctlDir := os.Getenv("EXPORT_FILE_PATH"); ctlDir != "" {
9393
// The dir must be writable by the (unprivileged) GPU-CR workloads
9494
// that mmap their dump buffers in it.
@@ -101,7 +101,7 @@ func main() {
101101
}
102102
// Sweep stale GPU-CR artifacts: a leaked dump pins its full extent
103103
// in shm/hugetlbfs even after the owning process dies.
104-
backends.StartGC(ctx, ctlDir, 10*time.Minute)
104+
utils.StartGPUCRSweeper(ctx, ctlDir, 10*time.Minute)
105105
}
106106

107107
slog.InfoContext(ctx, "Starting Snapshot Agent",
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package backends
1+
package utils
22

33
import (
44
"context"
@@ -29,8 +29,9 @@ var (
2929
// mmap'd them yet (files appear before the mapping does).
3030
const gcMinAge = 5 * time.Minute
3131

32-
// StartGC sweeps stale GPU-CR artifacts at startup and every interval.
33-
func StartGC(ctx context.Context, ctlDir string, interval time.Duration) {
32+
// StartGPUCRSweeper sweeps stale GPU-CR artifacts at startup and every
33+
// interval.
34+
func StartGPUCRSweeper(ctx context.Context, ctlDir string, interval time.Duration) {
3435
go func() {
3536
sweep(ctlDir)
3637
t := time.NewTicker(interval)

pkg/snapshot-agent/backends/gc_internal_test.go renamed to pkg/snapshot-agent/utils/gpu-cr_utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package backends
1+
package utils
22

33
import (
44
"os"

0 commit comments

Comments
 (0)