Skip to content

Fix silent/slow blockwise tmp-dir deletion and get_connected_ids overhead - #84

Merged
davidackerman merged 1 commit into
mainfrom
fix-blockwise-tmp-dir-deletion
Jul 21, 2026
Merged

davidackerman merged 1 commit into
mainfrom
fix-blockwise-tmp-dir-deletion

Conversation

@davidackerman

@davidackerman davidackerman commented Jul 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • get_zarr_chunk_path_from_block_index hand-joined block coordinates without accounting for Zarr v3's "c/" chunk-key prefix, so every distributed delete call in delete_tmp_dir_blockwise's zarr branch silently checked a nonexistent path and no-opped. All real cleanup fell to a single-threaded, unlogged final shutil.rmtree, which could take many minutes on network storage once chunk counts reach into the millions. Now uses the array's own chunk_key_encoding, correct for both v2 and v3.
  • delete_tmp_dir_blockwise now picks local (thread pool) vs. distributed deletion via a rough time estimate (local cores / num_workers / an assumed cluster-startup cost) instead of one fixed strategy per dir type; zarr and pickle-merge tmp dirs share the same decision logic.
  • get_connected_ids's post-scipy list-of-sets construction (np.split + set() per component) was itself a bottleneck at real dataset scale (~1.7M components); switched to plain list slicing, which downstream code doesn't need set-ness for.

…head

get_zarr_chunk_path_from_block_index hand-joined block coordinates
without accounting for Zarr v3's "c/" chunk-key prefix, so every
distributed delete call silently no-opped against a nonexistent path -
all real cleanup fell to a single-threaded, unlogged final rmtree that
could take many minutes on network storage with millions of chunks.
Use the array's own chunk_key_encoding instead, which is correct for
both v2 and v3.

delete_tmp_dir_blockwise now picks local (thread pool) vs distributed
deletion via a rough time estimate based on local cores, num_workers,
and an assumed cluster-startup cost, instead of always using one or the
other; both zarr and pickle-merge dirs share this same decision.

get_connected_ids's post-scipy list-of-sets construction (np.split +
set() per component) was itself a bottleneck at ~1.7M components;
switched to plain list slicing, which downstream code doesn't need
set-ness for.
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.12195% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.21%. Comparing base (1e21ddf) to head (811ace5).

Files with missing lines Patch % Lines
src/cellmap_analyze/util/dask_util.py 94.44% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #84      +/-   ##
==========================================
+ Coverage   84.10%   84.21%   +0.11%     
==========================================
  Files          28       28              
  Lines        4315     4339      +24     
==========================================
+ Hits         3629     3654      +25     
+ Misses        686      685       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@davidackerman
davidackerman merged commit 91b8127 into main Jul 21, 2026
3 checks passed
@davidackerman
davidackerman deleted the fix-blockwise-tmp-dir-deletion branch July 21, 2026 16:57
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.

1 participant