Share kodata across multi-arch builds?
Talking to @jonjohnsonjr I realized that we might be able to save some cycles if we found a way to share the kodata layer across architectures in multi-arch builds. Right now we are deterministically producing the same layer N times, but it should be safe to share this if we can find a way to reasonably do so.
This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.
This might be a little more complicated now with Windows support, since kodata is laid out differently in Windows layers.
I wonder if we could just not include the layer if kodata isn't present, rather than include an empty layer.
I think we want the directory to exist, even if it is empty.
Sure. What if we put the empty /var/run/kodata in the same layer as the binary, and if there's anything in kodata, put the rest in the separate layer. That way if there isn't any kodata we can skip a layer.
(This is also complicated by Windows-vs-Linux containers, but maybe a bit less)
I don't have a problem with that, though you should confirm it WAI since I think the layers are in the wrong order.
Kindly ping here; maybe we cannot add the data layer that includes /var/run/ko if there is no <importpath>/kodata existing in the project. WDYT?
/cc @dentrax
https://github.com/ko-build/ko/blob/5e0452ad67230076340d0e28dd8488e4370675c2/pkg/build/gobuild.go#L822-L842
I think we want to make sure there's an empty /var/run/ko directory even if there isn't a kodata directory to populate it.
The reason is that some code may depend on the var existing today even if it's empty, and changing that would break them.
The change is that /var/run/ko should be created in the binary layer instead of the data layer, so that the data layer can be omitted when there's no kodata.