Skip to content

test: add compress-to-zip tests#5933

Merged
Fedr merged 8 commits intomasterfrom
test/zip-compress-sphere
Apr 21, 2026
Merged

test: add compress-to-zip tests#5933
Fedr merged 8 commits intomasterfrom
test/zip-compress-sphere

Conversation

@Fedr
Copy link
Copy Markdown
Contributor

@Fedr Fedr commented Apr 19, 2026

What

Adds source/MRTest/MRZipCompressTests.cpp with two GoogleTest cases that exercise MeshLib's zip write path (compressZip → libzip → zlib deflate) on deliberately different workloads. Both are designed as realistic end-to-end benchmarks — easy to scale up for backend comparisons, small by default so they don't bloat the everyday MRTest run.

MRMesh.CompressSphereToZip

One large binary file.

  1. Creates a sphere via makeSphere({ radius=1, numMeshVertices=N }).
  2. Saves it as sphere.mrmesh in a UniqueTemporaryFolder.
  3. Compresses the folder into sphere.zip in a second temp folder (so the zip isn't inside the folder being compressed).
  4. Asserts both files exist and are non-empty; logs their sizes via spdlog::info.

Default N = 1000 vertices for the everyday run. Source comment documents bumping to N = 100_000 for benchmarking (produces a ~12 MB .mrmesh — closer to realistic scene data).

MRMesh.CompressManySmallFilesToZip

Many small mixed-type files. Pairs with the sphere test to compare one-large-file vs many-small-files on the same compressZip call.

  1. Writes numBinaryFiles .bin files of deterministic pseudo-random bytes (LCG-seeded per index; near-incompressible, representative of mesh coordinate floats / compressed-texture blobs).
  2. Writes numJsonFiles .json files of deterministic JSON-ish text padded to exactly bytesPerFile bytes (highly compressible, representative of scene metadata and logs).
  3. Compresses the folder into many.zip; asserts existence; logs input and output sizes.

Default (20 + 20) files × 6000 bytes = 240 KB for everyday runs. Source comment documents bumping to (200 + 200) × 60_000 = ~24 MB for benchmarking, matching the scaled-up sphere size.

Why two tests

libzip compresses each entry independently, so per-entry overhead (local file header, CRC32 pass, separate deflate session) is a different share of compressZip's time depending on whether the archive has one big file or many small ones. Having both tests in the same run surfaces that overhead clearly and lets compression-backend changes (e.g. PR #5932's zlib → zlib-ng overlay) be evaluated on both ends of the spectrum.

Measured compressZip time on bumped-up sizes (for reference)

Running the tests with the benchmark-size constants against MeshLib's Windows + Linux-vcpkg matrix, stock zlib vs zlib-ng (from PR #5932):

Matrix leg Sphere (12 MB single file) Many files (400 × 60 KB)
linux-vcpkg Release x64 Clang 20 −54% −62%
linux-vcpkg Release arm64 Clang 20 −45% −64%
linux-vcpkg Debug x64 GCC 11 −36% −62%
linux-vcpkg Debug arm64 GCC 11 −45% −63%
windows msvc-2022 Release CMake −48% −56%
windows msvc-2022 Debug MSBuild −24% −22%

(compressZip wall time as reported by MRTest's "Main thread time tree" dump at the end of the run.)

Many-small-files consistently sees a slightly larger speedup than one-large-file on Release; Debug is ~22-24% on both workloads.

No CMake / build changes

source/MRTest/CMakeLists.txt globs *.cpp, so the new file is picked up automatically. All dependencies (MRMesh, MRMeshSave, MRMakeSphereMesh, MRZip, MRUniqueTemporaryFolder, MRSpdlog) are already linked into MRTest.

Everyday vs benchmark runs

Defaults keep MRTest wall time short; scaling the file-count / vertex-count constants up turns either test into a compression benchmark without other changes. Both logged sizes via spdlog::info flow into the Unit Tests step output; the "Main thread time tree" dump at the end of MRTest reports per-call compressZip wall time in seconds.

Fedr added 3 commits April 19, 2026 15:05
Creates a sphere with ~100K vertices, saves it as a .mrmesh file in a
temporary folder, then calls compressZip to produce a .zip archive in
a second temporary folder. Verifies:
  - mesh and zip files both exist and are non-empty
  - the zip is not absurdly larger than the source (envelope sanity)

Serves as a realistic end-to-end exercise of MeshLib's zip write path
(libzip + zlib deflate) against mesh-sized data. Suitable for timing
comparisons of different zlib backends (e.g., stock zlib vs zlib-ng
compat) when added to a run's measurement targets.

Placed in source/MRTest/ as MRZipCompressTests.cpp; no CMake changes
needed (the existing file(GLOB SOURCES "*.cpp") picks it up).
Fedr added 4 commits April 20, 2026 19:03
New GTest case MRMesh.CompressManySmallFilesToZip writes 100 binary
files and 100 JSON files to a temp folder (each 60 000 bytes,
12 000 000 bytes total — matching the sphere.mrmesh size from the
existing CompressSphereToZip test) and compresses the folder to a
.zip.

Binary file content is deterministic pseudo-random bytes from a
per-index-seeded LCG — low-compressibility, representative of mesh
coordinate floats and similar near-incompressible payloads. JSON file
content is deterministic structured-looking text padded to exactly
60 000 bytes with trailing whitespace — highly compressible,
representative of scene-description metadata and logs.

Pairs with CompressSphereToZip so a single run of MRTest produces
two direct data points: one-large-file vs many-small-files on roughly
the same total byte budget. Useful for assessing libzip's per-entry
overhead (separate deflate session, CRC pass, local file header) when
comparing zlib backends or compression-level changes.

Per-file byte count is constant and deterministic so the aggregate
input size and zip size are stable across runs (modulo whatever
small variation deflate itself introduces on different zlib builds).

Logs totals via spdlog::info for easy diff with the other test.
…phere

# Conflicts:
#	source/MRTest/MRTest.vcxproj
@Fedr Fedr changed the title test: add sphere mesh compress-to-zip test test: add compress-to-zip tests Apr 21, 2026
@Fedr Fedr merged commit d9fb2d0 into master Apr 21, 2026
25 of 26 checks passed
@Fedr Fedr deleted the test/zip-compress-sphere branch April 21, 2026 18:35
Fedr added a commit that referenced this pull request Apr 23, 2026
Resolves conflicts from master's recent work (MRZlib move MRIOExtras→
MRMesh, #5948 adds MRZlibTests.cpp, #5933+#5960 overhaul CompressZip
tests, #5957 CUDA cache-key fix, #5722 triplet-keyed vcpkg cache).

Conflict resolutions:

  - .github/workflows/build-test-windows.yml — combined both sides'
    improvements in the cache key: master-side per-triplet partition
    (for the x64-windows-meshlib-iterator-debug triplet from #5722)
    AND branch-side hashFiles(overlay ports / triplets / requirements
    / install.bat) (from #5934, needed so overlay port changes on this
    PR bust the cache). Key is now
    vcpkg-cache-<VERSION>-<TRIPLET>-<HASH>.

  - source/MRMesh/MRZlib.h — accept master's version (master re-homed
    the file in #5944; branch had deleted it when it lived briefly in
    MRIOExtras).

  - source/MRIOExtras/MRZlib.{h,cpp} — follow master's layout: keep
    MRIOExtras/MRZlib.h as a forwarding header (#include
    <MRMesh/MRZlib.h>) and delete MRIOExtras/MRZlib.cpp (the old
    implementation body, now in MRMesh).

  - source/MRTest/MRTest.vcxproj — rename ClCompile entry from
    MRZlib.cpp to MRZlibTests.cpp to match master's #5948 test-file
    rename. Also drops the duplicate MRZlib.cpp entry.

  - source/MRTest/MRZlib.cpp — deleted, master renamed to
    MRZlibTests.cpp in #5948.

  - source/MRTest/MRZipCompressTests.cpp — accept master's version,
    which includes the level-0..9 loop (#5960) and the round-trip
    decompress check (#5958) on top of the branch's earlier simpler
    version. Branch-side novelty was just the sphere test itself,
    which is already on master.

  - source/MRTest/MRZlibTests.cpp — accept master's version,
    engine-agnostic assertions (tolerance-based compressedSize checks
    that I relaxed in the zlib-ng PR work).

Branch's unique contributions — the actual point of this PR — are
preserved:

  - thirdparty/vcpkg/ports/zlib/{portfile.cmake,vcpkg.json}  -- vcpkg
    overlay port that builds zlib-ng in ZLIB_COMPAT=ON as a drop-in
    zlib replacement for every port that depends on zlib.
  - thirdparty/install.bat  -- --overlay-ports flag added alongside
    the existing --overlay-triplets.
  - thirdparty/vcpkg/downloads/msys2-*.pkg.tar.zst  -- pre-staged
    msys2 packages so vcpkg's pinned 2024.10.21 index doesn't hit
    stale msys2 mirrors during vcpkg_fixup_pkgconfig().
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.

2 participants