cmd/compile: generics add significant build time and build size overhead #65605
go 1.20.7 linux/amd64 darwin/arm64
The text was updated successfully, but these errors were encountered:
@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:
@cespare yes, it's a fresh worker using the same code cache, i.e. not downloading it again. To reproduce locally I used
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.