Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
orf committed Jul 27, 2024
1 parent 9642158 commit 638f198
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ jobs:
fail-fast: false
matrix:
image:
- orfal/python:split-sorted-3.11
- orfal/python:3.11
- orfal/cuda:split-sorted-12.5.1-cudnn-devel-ubuntu20.04
- orfal/cuda:12.5.1-cudnn-devel-ubuntu20.04
- orfal/split:zstd-python-3.11
- orfal/split:original-python-3.11
- orfal/split:repacked-python-3.11
runs-on: ubuntu-latest
steps:
- name: Set up containerd
Expand Down
27 changes: 6 additions & 21 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ tasks:
- rm -rf oci/{{.image | replace ":" "/" }}/image_new/
- ./target/release/docker-repack oci/{{.image | replace ":" "/" }}/ --target-size=500MB --exclude='*.pyc' --split-file-threshold=25MB
- skopeo copy --override-arch=arm64 --override-os=linux oci:oci/{{.image | replace ":" "/" }}/image_new/ docker-daemon:foo:abc
# - docker run -it --entrypoint=bash foo:abc

run-and-export:
requires:
vars: [ 'image' ]
vars:
# image: 'nvidia/cuda:12.5.1-cudnn-devel-ubuntu20.04'
image: 'python:3.11'
compression_level: 9
image_path: 'oci/{{.image | replace ":" "/" }}'
image_slug: '{{.image | replace ":" "-" | replace "/" "-" }}'
tmp_dir:
sh: mktemp -d
interactive: true
cmds:
- cargo build --profile=release
- rm -rf oci/{{.image | replace ":" "/" }}/image_new/
Expand All @@ -34,23 +34,8 @@ tasks:
- skopeo copy --override-arch=arm64 --override-os=linux dir://{{.tmp_dir}} docker://orfal/split:zstd-{{.image_slug}}

test-all:
cmds:
- cargo build --release
- for: { var: IMAGES }
cmd: |
rm -rf oci/{{.ITEM | replace ":" "/" }}/image_new/
./target/release/docker-repack oci/{{.ITEM | replace ":" "/" }}/ --target-size=500MB --exclude='*.pyc'
echo {{.ITEM}}:
echo "Old":
du -hs oci/{{.ITEM | replace ":" "/" }}/image/blobs/sha256/
echo "New":
du -hs oci/{{.ITEM | replace ":" "/" }}/image_new/blobs/sha256/
skopeo copy --override-arch=arm64 --override-os=linux oci:oci/{{.ITEM | replace ":" "/" }}/image_new/ docker-daemon:foo/{{.ITEM}}
sync:
cmds:
- for: { var: IMAGES }
cmd: |
mkdir -p oci/{{.ITEM | replace ":" "/" }}/image/
skopeo copy --override-arch=arm64 --override-os=linux docker://docker.io/{{.ITEM}} oci:oci/{{.ITEM | replace ":" "/" }}/image/
task: run-and-export
vars:
image: '{{.ITEM}}'
7 changes: 6 additions & 1 deletion docker-repack/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ enum Command {
target_size: Byte,
#[arg(short, long)]
split_file_threshold: Option<Byte>,
#[arg(short, long, value_parser=parse_compression_level, default_value="7")]
#[arg(short, long, value_parser = parse_compression_level, default_value = "7")]
compression: CompressionLevel,
},
LargestFiles {
Expand Down Expand Up @@ -230,13 +230,18 @@ fn repack(
.sorted_by_key(|(layer, size)| (layer.type_, size.size))
.collect_vec();
image_writer.write_index(&sorted_layers, image)?;
let total_size = sorted_layers.iter().map(|(_, size)| size.size).sum::<u64>();
for (layer, hash_and_size) in sorted_layers {
println!(
"{layer} - compressed: {} / Size: {:#.1}",
hash_and_size.raw_hash(),
Byte::from(hash_and_size.size).get_appropriate_unit(UnitType::Decimal)
);
}
println!(
"Total image size: {:#.1}",
Byte::from(total_size).get_appropriate_unit(UnitType::Decimal)
);

Ok(())
}
Expand Down

0 comments on commit 638f198

Please sign in to comment.