mirror of
https://github.com/restic/restic.git
synced 2025-12-03 22:21:47 +00:00
archiver: unify FutureTree/File into futureNode
There is no real difference between the FutureTree and FutureFile structs. However, differentiating both increases the size of the FutureNode struct. The FutureNode struct is now only 16 bytes large on 64bit platforms. That way is has a very low overhead if the corresponding file/directory was not processed yet. There is a special case for nodes that were reused from the parent snapshot, as a go channel seems to have 96 bytes overhead which would result in a memory usage regression.
This commit is contained in:
@@ -28,19 +28,19 @@ func TestTreeSaver(t *testing.T) {
|
||||
|
||||
b := NewTreeSaver(ctx, wg, uint(runtime.NumCPU()), saveFn, errFn)
|
||||
|
||||
var results []FutureTree
|
||||
var results []FutureNode
|
||||
|
||||
for i := 0; i < 20; i++ {
|
||||
node := &restic.Node{
|
||||
Name: fmt.Sprintf("file-%d", i),
|
||||
}
|
||||
|
||||
fb := b.Save(ctx, "/", node, nil, nil)
|
||||
fb := b.Save(ctx, "/", node.Name, node, nil, nil)
|
||||
results = append(results, fb)
|
||||
}
|
||||
|
||||
for _, tree := range results {
|
||||
tree.Wait(ctx)
|
||||
tree.take(ctx)
|
||||
}
|
||||
|
||||
b.TriggerShutdown()
|
||||
@@ -89,19 +89,19 @@ func TestTreeSaverError(t *testing.T) {
|
||||
|
||||
b := NewTreeSaver(ctx, wg, uint(runtime.NumCPU()), saveFn, errFn)
|
||||
|
||||
var results []FutureTree
|
||||
var results []FutureNode
|
||||
|
||||
for i := 0; i < test.trees; i++ {
|
||||
node := &restic.Node{
|
||||
Name: fmt.Sprintf("file-%d", i),
|
||||
}
|
||||
|
||||
fb := b.Save(ctx, "/", node, nil, nil)
|
||||
fb := b.Save(ctx, "/", node.Name, node, nil, nil)
|
||||
results = append(results, fb)
|
||||
}
|
||||
|
||||
for _, tree := range results {
|
||||
tree.Wait(ctx)
|
||||
tree.take(ctx)
|
||||
}
|
||||
|
||||
b.TriggerShutdown()
|
||||
|
||||
Reference in New Issue
Block a user