-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.Performancehelp wantedv2An incompatible library changeAn incompatible library change
Milestone
Description
On my Mac laptop (SSD, warm caches),
bradfitz@laptop ~$ time (find src/ | wc -l)
42408
real 0m0.177s
user 0m0.035s
sys 0m0.144s
bradfitz@laptop ~$ time (find src/ | wc -l)
42408
real 0m0.178s
user 0m0.036s
sys 0m0.144s
bradfitz@laptop ~$ time (find src/ | wc -l)
42408
real 0m0.177s
user 0m0.035s
sys 0m0.144s
But with a basic use of filepath.Walk
instead of find
:
$ cat walk.go
package main
import (
"fmt"
"log"
"os"
"path/filepath"
)
func main() {
err := filepath.Walk("src", func(path string, fi os.FileInfo, err error) error {
if err != nil {
return err
}
fmt.Println(path)
return nil
})
if err != nil {
log.Fatal(err)
}
}
It's much slower:
bradfitz@laptop ~$ time (./walk | wc -l)
42408
real 0m0.447s
user 0m0.123s
sys 0m0.406s
bradfitz@laptop ~$ time (./walk | wc -l)
42408
real 0m0.434s
user 0m0.120s
sys 0m0.399s
bradfitz@laptop ~$ time (./walk | wc -l)
42408
real 0m0.435s
user 0m0.119s
sys 0m0.398s
This is the bulk of the goimports
execution time. goimports
actually does a slightly parallelized walk with goroutines (which helps on NFS filesystems), but it doesn't seem to matter. I'm just trying to get any Go program to be closer in performance to find
.
Any clues?
Speed tracking bug for goimports
is #16367
lafriakh, Maverobot, ktrueda, benhoyt, kylecarbs and 1 more
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.Performancehelp wantedv2An incompatible library changeAn incompatible library change