Background
bioio currently enforces a strict policy that readers must never hold an open file handle between operations. This policy originated to ensure that Reader objects are picklable for use with dask distributed computing (so dask workers can serialize and ship reader tasks across a cluster).
This came to our attention via bioio-devs/bioio-bioformats#51, where a user reported 200s load times for a 384-scene .stk file. The root cause: bioio's policy forces the bioformats reader to fully close and reinitialize the underlying Java reader object on every scene transition. At ~1 second per reinitialization × 384 scenes, the overhead is enormous. The same file loads in 1–2 seconds in Fiji.
As noted by contributors in that issue:
"bioio enforces that readers never hold an open file handle while they aren't actively reading image data, so the bioformats reader is forced to close the underlying java reader object and reopen it every time the scene is changed."
"Bioformats (java) is just fundamentally not particularly ready to support the model that bioio wants to enforce, where every operation leaves zero file handles open."
Expected Impact
This change should yield significant performance improvements for any reader that currently pays a per-operation reopen cost, not just bioio-bioformats. Any reader backed by a resource that is expensive to open (JVM-based readers, network file handles, etc.) would benefit.
References
Background
bioio currently enforces a strict policy that readers must never hold an open file handle between operations. This policy originated to ensure that
Readerobjects are picklable for use with dask distributed computing (so dask workers can serialize and ship reader tasks across a cluster).This came to our attention via bioio-devs/bioio-bioformats#51, where a user reported 200s load times for a 384-scene
.stkfile. The root cause: bioio's policy forces the bioformats reader to fully close and reinitialize the underlying Java reader object on every scene transition. At ~1 second per reinitialization × 384 scenes, the overhead is enormous. The same file loads in 1–2 seconds in Fiji.As noted by contributors in that issue:
Expected Impact
This change should yield significant performance improvements for any reader that currently pays a per-operation reopen cost, not just bioio-bioformats. Any reader backed by a resource that is expensive to open (JVM-based readers, network file handles, etc.) would benefit.
References