From 6ff9517e454b05d188cec1d19292f13293ddf394 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Fri, 19 Aug 2022 21:06:33 +0200 Subject: [PATCH] repository: MasterIndex.ListPacks / Index.EachByPack allow earlier GC Allow earlier garbage collection of some of the intermediate data structures. --- internal/repository/index.go | 2 ++ internal/repository/master_index.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/internal/repository/index.go b/internal/repository/index.go index 8978b60d5..767357eb3 100644 --- a/internal/repository/index.go +++ b/internal/repository/index.go @@ -294,6 +294,8 @@ func (idx *Index) EachByPack(ctx context.Context, packBlacklist restic.IDSet) <- result.Blobs = append(result.Blobs, idx.toPackedBlob(e, restic.BlobType(typ)).Blob) } } + // allow GC once entry is no longer necessary + byPack[packID] = nil select { case <-ctx.Done(): return diff --git a/internal/repository/master_index.go b/internal/repository/master_index.go index 955080e82..058a3a662 100644 --- a/internal/repository/master_index.go +++ b/internal/repository/master_index.go @@ -458,6 +458,8 @@ func (mi *MasterIndex) ListPacks(ctx context.Context, packs restic.IDSet) <-chan // pass on packs for packID, pbs := range packBlob { + // allow GC + packBlob[packID] = nil select { case out <- restic.PackBlobs{PackID: packID, Blobs: pbs}: case <-ctx.Done():