fix: reduce crawler memory usage by orders of magnitude (#11556)
currently crawler waits for an entire readdir call to return until it processes usage, lifecycle, replication and healing - instead we should pass the applicator all the way down to avoid building any special stack for all the contents in a single directory. This allows for - no need to remember the entire list of entries per directory before applying the required functions - no need to wait for entire readdir() call to finish before applying the required functionsmaster
parent
e07918abe3
commit
289e1d8b2a
@ -1,38 +0,0 @@ |
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// This code is imported from "golang.org/x/tools/internal/fastwalk",
|
||||
// only fastwalk.go is imported since we already implement readDir()
|
||||
// with some little tweaks.
|
||||
|
||||
package cmd |
||||
|
||||
import ( |
||||
"errors" |
||||
"os" |
||||
"strings" |
||||
) |
||||
|
||||
var errSkipFile = errors.New("fastwalk: skip this file") |
||||
|
||||
func readDirFn(dirName string, fn func(entName string, typ os.FileMode) error) error { |
||||
fis, err := readDir(dirName) |
||||
if err != nil { |
||||
if osIsNotExist(err) || err == errFileNotFound { |
||||
return nil |
||||
} |
||||
return err |
||||
} |
||||
for _, fi := range fis { |
||||
var mode os.FileMode |
||||
if strings.HasSuffix(fi, SlashSeparator) { |
||||
mode |= os.ModeDir |
||||
} |
||||
|
||||
if err = fn(fi, mode); err != nil { |
||||
return err |
||||
} |
||||
} |
||||
return nil |
||||
} |
Loading…
Reference in new issue