-
Notifications
You must be signed in to change notification settings - Fork 114
switch to rules_img and add image amd64/v3 variant #304
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
Conversation
|
c1688d0 to
909fda8
Compare
EdSchouten
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means we only end up publishing container images that use this. However, we also publish regular binaries through our CI pipeline. Can you make sure that those also get built for x86_64-v3?
Slightly annoying that the platforms module doesn't offer standardized definitions for this. A bit silly that both rules_go and rules_img need to declare their own constraints.
909fda8 to
2136596
Compare
I'll take a look. The workflow in .github/workflows/main.yaml is not exactly trivial, but I'll give it a shot. |
|
Note that the source of truth of those files lives in tools/github_workflows. Just "bazel build" and copy the outputs into .github. |
|
Happy to clean this up using the Jsonnet template as suggested, but before I do: CI seems to fail with "no space left on device". |
7d021a0 to
5971864
Compare
| "@rules_go//go/constraints/amd64:v3", | ||
| "@rules_img//img/constraints/amd64:v3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that we have similar constraints both on the rules_go and rules_img side makes me believe @platforms should be extended to offer those. Maybe it's worth filing an issue/submitting a PR there as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented on an existing issue: bazelbuild/platforms#13 (comment)
While I agree that this would be better, I'm unsure if a consensus can be reached over in the platforms repo.
f713e53 to
68555bb
Compare

This PR switches from rules_pkg and rules_oci to rules_img, thereby halving the container image size and offering an image that's optimized for x86-64-v3.
Space savings
Before, rules_pkg would not optimize the runfiles of the go_binary target in any way. Since Bazel binaries usually have a runfiles tree that contains the application itself, the image ends up containing the same data twice:
With rules_img, we can deduplicate multiple copies of the Go binary:
Architecture variants
The existing image index offers variants for linux/arm64 and linux/amd64. With this change, we also add a linux/amd64/v3 image variant that can be picked up by a compatible container runtime automatically.
This variant is compiled with the GOAMD64 value set to
v3, enabling newer CPU instructions that may accelerate CPU-intensive operations such as hashing.Older x86 CPUs can continue to use the baseline variant (linux/amd64).
I'm currently unable to provide a wide range of benchmarks (I'm travelling), but users are invited to test the image I pushed to ghcr.io/malt3/bb-storage:amd64v3 and report results.
I did compare the resulting binary with diffoscope and was able to verify that the linux/amd64/v3 binary does indeed contain instructions from newer architecture variants.