-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
cmd/compile: generics add significant build time and build size overhead #65605
Comments
Can you show us your code? Without that, it will be hard for us to look into it. |
It's possible to show code privately under NDA. Works for you? |
No, I'm not signing an NDA. |
Let me check. Maybe I can collect/provide some info which would be helpful? |
It would be interesting to see the output of |
ok. Can we send them to email in your github profile? |
Sure. |
Likely closely related to #51957 . |
@mdempsky This issue would at least be partially fixed by moving away from self-contained object files. Thin object files might help with the cpu, and almost certainly would help with the build cache size. |
Like @randall77 mentions, we're aware the compiler's intermediate files are larger than ideal, and unfortunately generics further aggravates that weakness. We have ideas about how to address that and intend to do those, but they're not trivial and will take time to implement and deploy. You also mention the size changes were due to switching to generics, which means your application code must have changed. That makes interpreting your benchmarks harder. For example, you say your CI now takes almost 3x as long, and suggest that's because generics are slower. But from your description, there's also the possibility that changing the application has simply created 3x more work for the compiler to do. I expect it's some of both. Certainly the compiler could be faster, but other projects are using generics successfully. For now, I think your best options are:
|
@xaurx could you clarify exactly what "Cold CI build time" means? Is that the time it takes merely to run |
@cespare yes, it's a fresh worker using the same code cache, i.e. not downloading it again. To reproduce locally I used w/o generics:
w/ generics:
as you can see, after adding generics compile time becomes 4.2x slower and takes 5.7x more disk space in go-build cache. |
@mdempsky see exact commands I used to reproduce in above message. i.e. it's not about some other changes in the code. any fresh build after Please note, any package which imports the one used generics now takes so much significantly more time to build. Since we import it a lot of times - it adds up and overall build takes long. |
Go version
go 1.20.7 linux/amd64 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
We have a large DB-like solution in golang. This project has a fancy b-tree implementation with around 10x B-tree instances working with different key/value structs using interface{}.
To save some memory and improve the performance we recently switched to generics, so B-Tree is now a parametrized struct with key/value types.
What did you see happen?
We found the following important issues after switching to generics:
All of those seem rather bad and I hope someone would be interested looking into it.
What did you expect to see?
Not so significant build time and go build cache size changes.
Executable size is not so important, though is very surprising as well.
The text was updated successfully, but these errors were encountered: