Skip to content

perf(investigate): svs → cog-wsi verbatim tile-copy ~10x slower than tiff/ome-tiff for identical output (IFD spooling path?) #37

Description

@cornish

Type

Perf / investigation (not a confirmed defect) — may well be inherent to the COG-WSI layout; filing so the cost is measured and the spool path is looked at deliberately.

Observation

A no-transform, no-codec-change convert (verbatim tile-copy) from SVS to cog-wsi runs ~10× slower than the same tile-copy to tiff/ome-tiff, for byte-identical output size. Controlled, back-to-back, -q, same source (CMU-2.svs, 78000×30462, jpeg tiles):

svs -> ome-tiff   1.08s / 0.94s     out 402,743,571
svs -> tiff       0.94s / 0.97s     out 402,740,907
svs -> cog-wsi    9.95s / 9.90s     out 402,717,328

Reproducible and stable when isolated (run-to-run variance in a full batch was just concurrency). Output size ≈ the jpeg copies, so tiles are not being re-encoded to htj2k — the same compressed bytes are written, but the cog-wsi writer spends ~9s of extra wall-clock the plain-TIFF / OME-TIFF writers don't.

Repro:

wsitools convert --to tiff     -q -f -o out.tiff     CMU-2.svs   # ~1s
wsitools convert --to ome-tiff -q -f -o out.ome.tiff CMU-2.svs   # ~1s
wsitools convert --to cog-wsi  -q -f -o out.cog.tiff CMU-2.svs   # ~10s

Probable cause

COG-WSI writes its IFDs up front (offsets must precede the tile data for a cloud-optimized layout), so later IFDs have to be spooled to generate the pointers — an extra pass / buffering that the append-as-you-go plain-TIFF and OME-TIFF writers avoid. So some overhead is expected by construction.

Question for the investigation

Is the ~10× (≈9s of added wall-clock on a ~400 MB verbatim copy) proportionate to the unavoidable spooling, or is there avoidable per-tile overhead in the spool path — e.g. an extra decode/copy pass, per-tile allocation, unbuffered spool I/O, or work that could be single-pass with offset back-patching? A quick profile of the cogwsi write path on this input would settle whether ~10× is the floor or has headroom.

Likely related: #3 (deterministic write mode for cogwsiwriter).

Environment

wsitools 0.26.3, Windows (MSYS2/MinGW). Numbers above are from tile-copy (no --codec, no transform).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions