Skip to content

Commit

Permalink
gc: remove unneccessary full repo scan
Browse files Browse the repository at this point in the history
GetStorageUsage() is super expensive as it involves a full repo scan,
and it's already bad enough that we have do it once.

The call that's being removed here is purely for cosmetical purposes:
printing the number of bytes freed by the GC run. Let's drop it.

License: MIT
Signed-off-by: Lars Gierth <larsg@systemli.org>
  • Loading branch information
Lars Gierth committed Dec 9, 2016
1 parent a9b8c8b commit 8f0c7ee
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions core/corerepo/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,7 @@ func (gc *GC) maybeGC(ctx context.Context, offset uint64) error {
if err := GarbageCollect(gc.Node, ctx); err != nil {
return err
}
newStorage, err := gc.Repo.GetStorageUsage()
if err != nil {
return err
}
log.Infof("Repo GC done. Released %s\n", humanize.Bytes(uint64(storage-newStorage)))
if newStorage > gc.StorageGC {
log.Warningf("post-GC: Watermark still exceeded")
if newStorage > gc.StorageMax {
err := ErrMaxStorageExceeded
log.Error(err)
return err
}
}
log.Infof("Repo GC done. See `ipfs repo stat` to see how much space got freed.\n")
}
return nil
}

0 comments on commit 8f0c7ee

Please sign in to comment.