ko icon indicating copy to clipboard operation
ko copied to clipboard

Share kodata across multi-arch builds?

Open mattmoor opened this issue 3 years ago • 7 comments

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.

mattmoor avatar Dec 12 '20 03:12 mattmoor

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.

github-actions[bot] avatar Mar 13 '21 01:03 github-actions[bot]

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.

imjasonh avatar Aug 20 '21 01:08 imjasonh

I think we want the directory to exist, even if it is empty.

mattmoor avatar Aug 20 '21 02:08 mattmoor

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)

imjasonh avatar Aug 20 '21 02:08 imjasonh

I don't have a problem with that, though you should confirm it WAI since I think the layers are in the wrong order.

mattmoor avatar Aug 20 '21 14:08 mattmoor

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

developer-guy avatar Oct 13 '22 11:10 developer-guy

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.

imjasonh avatar Oct 13 '22 20:10 imjasonh