User fewer hasher routines when there are many folders.
This commit is contained in:
@@ -89,14 +89,9 @@ func (w *Walker) Walk() (chan protocol.FileInfo, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
workers := w.Hashers
|
||||
if workers < 1 {
|
||||
workers = runtime.NumCPU()
|
||||
}
|
||||
|
||||
files := make(chan protocol.FileInfo)
|
||||
hashedFiles := make(chan protocol.FileInfo)
|
||||
newParallelHasher(w.Dir, w.BlockSize, workers, hashedFiles, files)
|
||||
newParallelHasher(w.Dir, w.BlockSize, w.Hashers, hashedFiles, files)
|
||||
|
||||
go func() {
|
||||
hashFiles := w.walkAndHashFiles(files)
|
||||
|
||||
@@ -63,6 +63,7 @@ func TestWalkSub(t *testing.T) {
|
||||
Subs: []string{"dir2"},
|
||||
BlockSize: 128 * 1024,
|
||||
Matcher: ignores,
|
||||
Hashers: 2,
|
||||
}
|
||||
fchan, err := w.Walk()
|
||||
var files []protocol.FileInfo
|
||||
@@ -99,6 +100,7 @@ func TestWalk(t *testing.T) {
|
||||
Dir: "testdata",
|
||||
BlockSize: 128 * 1024,
|
||||
Matcher: ignores,
|
||||
Hashers: 2,
|
||||
}
|
||||
|
||||
fchan, err := w.Walk()
|
||||
@@ -122,6 +124,7 @@ func TestWalkError(t *testing.T) {
|
||||
w := Walker{
|
||||
Dir: "testdata-missing",
|
||||
BlockSize: 128 * 1024,
|
||||
Hashers: 2,
|
||||
}
|
||||
_, err := w.Walk()
|
||||
|
||||
@@ -280,6 +283,7 @@ func walkDir(dir string) ([]protocol.FileInfo, error) {
|
||||
Dir: dir,
|
||||
BlockSize: 128 * 1024,
|
||||
AutoNormalize: true,
|
||||
Hashers: 2,
|
||||
}
|
||||
|
||||
fchan, err := w.Walk()
|
||||
|
||||
Reference in New Issue
Block a user