Half-baked idea: Compile Go code efficiently with a new buildkit frontend #3778
Replies: 2 comments 1 reply
-
Related idea I had to speed up remote caching is to replicate them asynchronously from the build, maybe something like Kraken. Even at a trickle, surely this would result in more cache hits than 0. |
Beta Was this translation helpful? Give feedback.
-
If you are thinking about all go pkg builds as separate build steps and with precise cache rules from source files then I did do this while back as an example https://github.com/tonistiigi/llb-gobuild (it's likely not functional anymore, but you can look at how it worked). If you are thinking of mainly avoiding Dockerfiles then you could definitely build something like |
Beta Was this translation helpful? Give feedback.
-
I've been thinking a long time about building Go code in CI and making that efficient.
The standard Go toolchain has caching for module source downloads, builds, and test results. But in my experience, these are only every really fully utilized during local development. Sharing the build cache is, in my experience, not done in CI, for reasons I might get into later, but mostly because it doesn't yield a significant speed increase for building code.
However, I still think it might be fun to try.
So anyway, my idea is to create a custom Buildkit frontend that builds some Go binary. The build file would basically just be the arguments to
go build
, plus the source probably. The output image would be the binary. The Go toolchain would have to be hacked somehow to use buildkit to cache intermediate results in its cache.Obviously converting the Go compiler to generate the LLB tree would be quite the undertaking, not to mention the burden of maintaining what is essentially a fork. That's probably out of the question, so I think for now I'd just like a protoype.
I'm wondering if anyone has a rough idea of how much work such a thing would be? There are not a ton of examples of custom frontends out there, nor docs on creating one. I could figure it out. But thought I'd ask first.
Beta Was this translation helpful? Give feedback.
All reactions