Skip to content

write10xCounts() writes data/indices as a single HDF5 chunk, causing slowdowns/failures in streaming readers #131

Description

@stephenwilliams22

write10xCounts() appears to rely on HDF5's default auto-chunking for the matrix/data and matrix/indices datasets, which for a large 1-D array resolves to a single chunk spanning nearly the whole dataset. Since HDF5's chunk cache defaults to 1 MiB, any reader that streams the matrix in bounded slices (rather than loading it all at once) can't retain a decompressed chunk between calls, so every small read redecompresses a possible multi-GB chunk from scratch.

A possible fix: When creating the matrix/data, matrix/indices (and similarly the barcodes/features columns), explicitly pass a bounded chunk size, e.g. chunk_dims = min(length(x), 1e6), instead of leaving it to HDF5's default auto-chunking, which for a single large 1-D vector tends to pick a chunk size close to the full dataset length.

An example for this would be anndataR's fix to address a similar issue scverse/anndataR#424

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions