diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index 8f35a9f..4ebf1c9 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -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 diff --git a/Taskfile.yaml b/Taskfile.yaml index 29313d7..d4d2647 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -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/ @@ -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}}' diff --git a/docker-repack/src/main.rs b/docker-repack/src/main.rs index dc024ce..6a8099b 100644 --- a/docker-repack/src/main.rs +++ b/docker-repack/src/main.rs @@ -38,7 +38,7 @@ enum Command { target_size: Byte, #[arg(short, long)] split_file_threshold: Option, - #[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 { @@ -230,6 +230,7 @@ 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::(); for (layer, hash_and_size) in sorted_layers { println!( "{layer} - compressed: {} / Size: {:#.1}", @@ -237,6 +238,10 @@ fn repack( 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(()) }