Skip to content

feat(perf): Add tile batching optimization for CoolerTileset - #10

Merged
nvictus merged 3 commits into
mainfrom
feat-cooler-tile-batching
Sep 18, 2026
Merged

nvictus merged 3 commits into
mainfrom
feat-cooler-tile-batching

Conversation

@nvictus

@nvictus nvictus commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Restores tile batching optimization as found in the legacy cooler tileset, but improved and with greater flexibility.

Tiles from a request batch are grouped by zoom and transform. Then, within a group the reader merges queries whose bin ranges are contiguous in the cooler's own bin ordering. Finally, the merged rectangle is sliced back into per-tile blocks.

Consulting the file's internal ordering rather than what we project on the canvas makes it safe for us to project a chromosome order that differs from the file's (though, this option is not exposed yet!) This is now exposed via an optional chromsizes argument to the tileset constructor. Tiles that are adjacent on the canvas are then not adjacent on disk, and simply would not merge.

We re-use cooler's internal query engine machinery for the design:

  1. Because pixels are stored CSR, merging fetches of horizontally-adjacent bboxes eliminates multiple fetches of the same matrix rows from disk. For bboxes crossing the diagonal in symmetric-upper mode, vertical consolidation also eliminates redundant I/O.

  2. As an additional optimization, fetches go through cooler's internal query engines rather than Cooler.matrix() to read the internal index only once for the whole batch.

The original, and simpler, non-batched query mode is preserved by passing batched=False.

@nvictus
nvictus force-pushed the feat-cooler-tile-batching branch from 8778ce6 to c962c36 Compare September 17, 2026 20:00
@nvictus
nvictus force-pushed the feat-cooler-tile-batching branch from c962c36 to 1615857 Compare September 18, 2026 01:26
@nvictus
nvictus force-pushed the feat-cooler-tile-batching branch from 1b85f52 to 0074bd1 Compare September 18, 2026 01:58
@nvictus
nvictus merged commit aebeeab into main Sep 18, 2026
2 checks passed
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