-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/tools/internal/gopathwalk: regression in module cache scan performance #65531
Comments
Change https://go.dev/cl/561655 mentions this issue: |
Change https://go.dev/cl/561675 mentions this issue: |
A comparison of reverting vs fixing forward, in a relatively stable development environment. For lack of better names, "fastwalk.txt" is the revert, and "bryan.txt" is the fix forward :).
Limiting concurrency of the fix forward to 4 (the nominal concurrency limit of fastwalk), and results were noticeably worse:
However, CPU profiling indicated that the fix forward only uses 25% more CPU than fastwalk, so we can perhaps just say this is due to differences in scheduling, and run with the default concurrency of GOMAXPROCS. Notably, the fix forward is still 4x faster than the non-concurrent implementation:
Therefore, I think we should fix forward. I'd rather get this fix into the gopls prerelease, so that it can get some exposure. |
Ah, turns out that I misread the old code. 4 goroutines was the minimum; |
Oh, I misread it too! Then everything makes sense. |
As described in the discussion of https://go.dev/cl/508506, simplifying gopathwalk to use filepath.WalkDir had the unfortunate consequence of significantly slowing performance when starting from a cold module cache, as would be the case when running goimports from the command line. This is also very noticeable when gopls is initially started. On my laptop, with a 19GB module cache, warming up goimports went from ~6s to ~30s.
Because this latency was already a concern for gopls (see #44863), I don't think we can afford such a significant regression. With that said, the regression is probably possible to mitigate with alternative concurrency strategies. A benchmark is added in https://go.dev/cl/561436 which we can use for revisiting the simplification. For now, I think we need to temporarily revert CL 508506.
CC @bcmills
The text was updated successfully, but these errors were encountered: