bazel-gazelle icon indicating copy to clipboard operation
bazel-gazelle copied to clipboard

Parallel walk?

Open pcj opened this issue 2 years ago • 3 comments

It seems like gazelle should be theoretically parallelizable when walking the filesystem, as separate subtrees are supposed to be independent. However, it would require that things like config access and other operations are protected against concurrent writes, etc.

I assume this has been thought of, any particular design decisions on this? cc @jayconrod

pcj avatar Oct 12 '21 18:10 pcj

I can't think of any reason that this wouldn't work, other than being some significant implementation work.

robfig avatar Oct 16 '21 14:10 robfig

We're discussing this FR right now in the gazelle contributors meeting.

We'd like to add a profiler first so it's more clear to us/users whether the serial tree-walk is the bottleneck. @robfig do you have any input that could help someone contribute this? Some rough design sketch or pointers where you would make the change?

alexeagle avatar Apr 28 '22 16:04 alexeagle

Go has a very robust system for profiling where you add (copied from their docs) something like

var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to `file`")
var memprofile = flag.String("memprofile", "", "write memory profile to `file`")

func main() {
    flag.Parse()
    if *cpuprofile != "" {
        f, err := os.Create(*cpuprofile)
        if err != nil {
            log.Fatal("could not create CPU profile: ", err)
        }
        defer f.Close() // error handling omitted for example
        if err := pprof.StartCPUProfile(f); err != nil {
            log.Fatal("could not start CPU profile: ", err)
        }
        defer pprof.StopCPUProfile()
    }

    // ... rest of the program ...

Have we tried adding something like that to the commands you want to profile?

achew22 avatar Apr 28 '22 16:04 achew22