Skip to content
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

ui: add empty go.mod files to workspaces #99775

Merged
merged 1 commit into from
May 30, 2023

Conversation

stevendanna
Copy link
Collaborator

@stevendanna stevendanna commented Mar 28, 2023

Some go tools such as go list end up traversing directories that don't have go.mod files, looking for go packages.

If you happen to have built the UI recently, that means tens of thousands of extra stat calls.

On macOS, this is very expensive, even with warm caches.

For example:


time go list -modfile=go.mod -mod=readonly -e ARGS_ELIDED  -- builtin github.com/cockroachdb/cockroach/... > /dev/null 2>&1

real    0m28.309s
user    0m23.541s
sys     0m50.926s

> for i in pkg/ui/workspaces/*/; do touch $i/go.mod; done

> time go list -modfile=go.mod -mod=readonly -e ARGS_ELIDED -- builtin github.com/cockroachdb/cockroach/... > /dev/null 2>&1

real    0m13.074s
user    0m18.282s
sys     0m19.324s

The go list command I used was taken from what I observed gopls running at startup.

On Linux, the impact relatively modest.

I could avoid building the UI, but I like the UI.

Epic: none

Release note: none

@stevendanna stevendanna marked this pull request as ready for review March 28, 2023 08:20
@stevendanna stevendanna requested a review from a team March 28, 2023 08:20
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thank you

Some go tools such as go list end up traversing directories that don't
have go.mod files, looking for go packages.

If you happen to have built the UI recently, that means about tens of
thousands of extra stat calls.

On macOS, this is very expensive, even with warm caches.

For example:
```

time go list -modfile=go.mod -mod=readonly -e ARGS_ELIDED  -- builtin github.com/cockroachdb/cockroach/... > /dev/null 2>&1

real    0m28.309s
user    0m23.541s
sys     0m50.926s

> for i in pkg/ui/workspaces/*/; do touch $i/go.mod; done

> time go list -modfile=go.mod -mod=readonly -e ARGS_ELIDED -- builtin github.com/cockroachdb/cockroach/... > /dev/null 2>&1

real    0m13.074s
user    0m18.282s
sys     0m19.324s
```

The go list command I used was taken from what I observed gopls
running at startup.

On Linux, the impact relatively modest.

I could avoid building the UI, but I like the UI.

Epic: none

Release note: none
@stevendanna
Copy link
Collaborator Author

bors r=knz

@craig
Copy link
Contributor

craig bot commented May 30, 2023

Build succeeded:

@craig craig bot merged commit 48c2bc6 into cockroachdb:master May 30, 2023
craig bot pushed a commit that referenced this pull request Nov 8, 2024
`go list` (which is invoked occasionally GoLand) throws a "missing module
declaration" error on the empty `go.mod` files that were created in
#99775 (to prevent `go list` from
recursing into subdirectories to save IO).

Now we make actual empty named modules, which seems to work better.

```
for i in pkg/ui/workspaces/*/
  do echo "module $(basename $i | sed 's/[^a-z]//g')" > $i/go.mod
done
```

Epic: none
craig bot pushed a commit that referenced this pull request Nov 8, 2024
127867: workspaces: create actual dummy go modules r=tbg a=tbg

`go list` (which is invoked occasionally GoLand) throws a "missing module
declaration" error on the empty `go.mod` files that were created in
#99775 (to prevent `go list` from
recursing into subdirectories to save IO).

Now we make actual empty named modules, which seems to work better.

```
for i in pkg/ui/workspaces/*/
  do echo "module $(basename $i | sed 's/[^a-z]//g')" > $i/go.mod
done
```

Epic: none


Co-authored-by: Tobias Grieger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants