Skip to content

Conversation

allisonkarlitskaya
Copy link
Contributor

The internal detail of how we handle the exit of the child process leads to the entire ImageProxy struct not being Send, which means that it can't be used in cross-thread Futures with tokio. Fortunately it's a very simple fix.

Add some trivial static testing to make sure this doesn't regress. Add it for OpenedImage as well: it's currently trivially Send+Sync on account of being a wrapper around an integer, but this might change in the future.

This change has been cross-checked against both bootc (ostree-ext) and composefs-rs and doesn't cause any issues.

The internal detail of how we handle the exit of the child process leads
to the entire ImageProxy struct not being Send, which means that it
can't be used in cross-thread Futures with tokio.  Fortunately it's a
very simple fix.

Add some trivial static testing to make sure this doesn't regress.  Add
it for OpenedImage as well: it's currently trivially Send+Sync on
account of being a wrapper around an integer, but this might change in
the future.

This change has been cross-checked against both bootc (ostree-ext) and
composefs-rs and doesn't cause any issues.

Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
Copy link
Collaborator

@jeckersb jeckersb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! ✉️ 🔄

@jeckersb jeckersb merged commit 0bb03ce into bootc-dev:main Apr 21, 2025
2 checks passed
allisonkarlitskaya added a commit to allisonkarlitskaya/composefs-rs that referenced this pull request Apr 22, 2025
Add an async version of `Repository::ensure_object()` and wire it
through `SplitStreamWriter::write_external()`.  Call that when we're
splitting OCI layer tarballs to offload the writing of external objects
(and the `fdatasync()` that goes with it) to a separate thread.  This is
something like some prep work for something we've been trying to
accomplish for a while in containers#62 but it doesn't come close to the complete
picture (since it still writes the objects sequentially).

Modify the (already) async code in oci::ImageOp to download layers in
parallel.  This is a big deal for images with many layers (as is often
the case for bootc images, due to the splitting heuristics).  This takes
a pull of the Fedora Silverblue 42 container image (when pulled from a
local `oci-dir`) from ~90s to ~8.5s time to complete on my laptop.

Unfortunately, container images made from large single layers are not
substantially improved.

In order to make this change we need to depend on a pre-release version
of containers-image-proxy-rs which makes ImageProxy: Send + Sync.  See
bootc-dev/containers-image-proxy-rs#78 for
that.  This prevents us from publishing ourselves for now, so make our
check for that non-fatal.

Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
allisonkarlitskaya added a commit to allisonkarlitskaya/composefs-rs that referenced this pull request Apr 22, 2025
Add an async version of `Repository::ensure_object()` and wire it
through `SplitStreamWriter::write_external()`.  Call that when we're
splitting OCI layer tarballs to offload the writing of external objects
(and the `fdatasync()` that goes with it) to a separate thread.  This is
something like some prep work for something we've been trying to
accomplish for a while in containers#62 but it doesn't come close to the complete
picture (since it still writes the objects sequentially).

Modify the (already) async code in oci::ImageOp to download layers in
parallel.  This is a big deal for images with many layers (as is often
the case for bootc images, due to the splitting heuristics).  This takes
a pull of the Fedora Silverblue 42 container image (when pulled from a
local `oci-dir`) from ~90s to ~8.5s time to complete on my laptop.

Unfortunately, container images made from large single layers are not
substantially improved.

In order to make this change we need to depend on a pre-release version
of containers-image-proxy-rs which makes ImageProxy: Send + Sync.  See
bootc-dev/containers-image-proxy-rs#78 for
that.  This prevents us from publishing ourselves for now, so make our
check for that non-fatal.

Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
allisonkarlitskaya added a commit to allisonkarlitskaya/composefs-rs that referenced this pull request Apr 22, 2025
Add an async version of `Repository::ensure_object()` and wire it
through `SplitStreamWriter::write_external()`.  Call that when we're
splitting OCI layer tarballs to offload the writing of external objects
(and the `fdatasync()` that goes with it) to a separate thread.  This is
something like some prep work for something we've been trying to
accomplish for a while in containers#62 but it doesn't come close to the complete
picture (since it still writes the objects sequentially).

Modify the (already) async code in oci::ImageOp to download layers in
parallel.  This is a big deal for images with many layers (as is often
the case for bootc images, due to the splitting heuristics).  This takes
a pull of the Fedora Silverblue 42 container image (when pulled from a
local `oci-dir`) from ~90s to ~8.5s time to complete on my laptop.

Unfortunately, container images made from large single layers are not
substantially improved.

In order to make this change we need to depend on a pre-release version
of containers-image-proxy-rs which makes ImageProxy: Send + Sync.  See
bootc-dev/containers-image-proxy-rs#78 for
that.  This prevents us from publishing ourselves for now, so make our
check for that non-fatal.

Signed-off-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
@cgwalters
Copy link
Collaborator

Also related #31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants