Skip to content

Splitting blocks larger than supported.#968

Merged
bbuchfink merged 1 commit into
bbuchfink:masterfrom
bbuschkaemper:32bit-block-limit
Jun 27, 2026
Merged

Splitting blocks larger than supported.#968
bbuchfink merged 1 commit into
bbuchfink:masterfrom
bbuschkaemper:32bit-block-limit

Conversation

@bbuschkaemper

Copy link
Copy Markdown
Contributor

Length-sorted blocks can exceed 4.3B sequences which causes overflow on the 32bit per-block sequence ids.

Summary

Prevent large-memory deepclust length sorting from creating input blocks that exceed 2^32-1 by creating additional input blocks when exceeding a limit. Currently for:

  • Per-block sequence ids (32-bit)
  • Packed sequence offsets (40-bit)

Details

  • Add Cluster::Multinode::can_add_to_len_sorted_block() to centralize length-sort block limit checks.
  • Cap blocks by requested letter block size and current representation limits.
  • Preserve single-sequence block behavior when one sequence exceeds the requested letter block size but still fits representation limits (should never happen).
  • Fail clearly if one sequence exceeds the packed offset limit (should never happen).
  • Fail clearly for custom non-linear first rounds requiring multiple capped input blocks, because that path currently only processes input0.faa.
  • Propagate length-sort failures to waiting multiprocessing workers via a lensort_error marker to avoid hangs (just for bookkeeping to have all threads throw a clean error).
  • Unit test to enforce block-limit boundary behaviors.

Validation

  • cmake --build diamond/build --target diamond -j 128
  • ctest --test-dir diamond/build --output-on-failure

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents multinode/deepclust length-sorting from producing input blocks that exceed current representation limits (32-bit per-block sequence IDs and 40-bit packed offsets), and propagates failures cleanly to other workers instead of hanging.

Changes:

  • Added Cluster::Multinode::can_add_to_len_sorted_block() plus shared constants to centralize block limit checks for length-sorted inputs.
  • Updated len_sort() to split/cap blocks using the centralized limit logic and to propagate errors via a lensort_error marker file.
  • Added a small unit-style check for boundary behaviors and wired it into CTest.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/test/test.cpp Adds a minimal unit-style test for can_add_to_len_sorted_block() boundary cases.
src/cluster/multinode/len_sort.h Introduces shared constants and the can_add_to_len_sorted_block() declaration.
src/cluster/multinode/len_sort.cpp Implements block-limit logic, updates len-sorting to respect limits, and adds error propagation to avoid worker hangs.
CMakeLists.txt Registers a new unit test in CTest.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CMakeLists.txt
add_test(NAME linclust COMMAND ${CMAKE_COMMAND} -DNAME=linclust "-DARGS=linclust -d ${TD}/nr_10k.faa -p4 --approx-id 0" ${SP})
add_test(NAME linclust_reps COMMAND ${CMAKE_COMMAND} -DTEST_DIR=${CMAKE_SOURCE_DIR}/src/test -P ${CMAKE_SOURCE_DIR}/src/test/linclust_reps.cmake)
add_test(NAME realign COMMAND ${CMAKE_COMMAND} -DNAME=realign "-DARGS=realign -d ${TD}/nr_10k.faa -p1 --clusters ${TD}/linclust.out" ${SP})
add_test(NAME unit COMMAND diamond test)

namespace Cluster { namespace Multinode {

constexpr uint64_t LEN_SORT_BLOCK_SEQ_LIMIT = (uint64_t)std::numeric_limits<BlockId>::max() - 1;
Comment on lines +257 to +258
if (seqs == 0)
throw runtime_error("Sequence exceeds supported maximum block size.");
@bbuchfink bbuchfink merged commit 3e34328 into bbuchfink:master Jun 27, 2026
6 checks passed
@bbuschkaemper bbuschkaemper deleted the 32bit-block-limit branch June 27, 2026 18:01
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.

3 participants