mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 14:56:29 +00:00
repo: Remove packer limits
This commit simplifies finding a packer: The first open packer is taken, and the upper limit for the pack file is removed.
This commit is contained in:
parent
d3fee08f9a
commit
db0e3cd772
@ -38,8 +38,6 @@ type packerManager struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const minPackSize = 4 * 1024 * 1024
|
const minPackSize = 4 * 1024 * 1024
|
||||||
const maxPackSize = 16 * 1024 * 1024
|
|
||||||
const maxPackers = 200
|
|
||||||
|
|
||||||
// newPackerManager returns an new packer manager which writes temporary files
|
// newPackerManager returns an new packer manager which writes temporary files
|
||||||
// to a temporary directory
|
// to a temporary directory
|
||||||
@ -58,16 +56,10 @@ func (r *packerManager) findPacker(size uint) (packer *Packer, err error) {
|
|||||||
|
|
||||||
// search for a suitable packer
|
// search for a suitable packer
|
||||||
if len(r.packers) > 0 {
|
if len(r.packers) > 0 {
|
||||||
debug.Log("searching packer for %d bytes\n", size)
|
p := r.packers[0]
|
||||||
for i, p := range r.packers {
|
r.packers = r.packers[1:]
|
||||||
if p.Packer.Size()+size < maxPackSize {
|
|
||||||
debug.Log("found packer %v", p)
|
|
||||||
// remove from list
|
|
||||||
r.packers = append(r.packers[:i], r.packers[i+1:]...)
|
|
||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// no suitable packer found, return new
|
// no suitable packer found, return new
|
||||||
debug.Log("create new pack for %d bytes", size)
|
debug.Log("create new pack for %d bytes", size)
|
||||||
|
@ -91,7 +91,7 @@ func fillPacks(t testing.TB, rnd *randReader, be Saver, pm *packerManager, buf [
|
|||||||
}
|
}
|
||||||
bytes += l
|
bytes += l
|
||||||
|
|
||||||
if packer.Size() < minPackSize && pm.countPacker() < maxPackers {
|
if packer.Size() < minPackSize {
|
||||||
pm.insertPacker(packer)
|
pm.insertPacker(packer)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -191,9 +191,8 @@ func (r *Repository) SaveAndEncrypt(ctx context.Context, t restic.BlobType, data
|
|||||||
return restic.ID{}, err
|
return restic.ID{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the pack is not full enough and there are less than maxPackers
|
// if the pack is not full enough, put back to the list
|
||||||
// packers, put back to the list
|
if packer.Size() < minPackSize {
|
||||||
if packer.Size() < minPackSize && r.countPacker() < maxPackers {
|
|
||||||
debug.Log("pack is not full enough (%d bytes)", packer.Size())
|
debug.Log("pack is not full enough (%d bytes)", packer.Size())
|
||||||
r.insertPacker(packer)
|
r.insertPacker(packer)
|
||||||
return *id, nil
|
return *id, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user