Conversation
… thread counts (OpenGene#721) Restore two critical synchronization signals in SingleProducerSingleConsumerList: 1. Uncomment head->nextItemReady signal on first produce: when the first item is added to an empty queue, explicitly mark it ready for consumption. Without this, canBeConsumed() returns false even though an item exists, causing consumers to block indefinitely. 2. Add (head == tail) check in canBeConsumed(): the last item in the queue has no successor, so nextItemReady remains false until a second item is produced. The safety check ensures the tail item is always consumable, preventing writer thread stalls when many queues exist with sparse items. This regression was introduced when reverting unrelated deadlock fix, causing hang during paired-end adapter detection with 48+ worker threads on large FASTQ files. Each thread gets a dedicated queue; with high thread counts, queue depth drops to 1-2 items per thread. Without these signals, writer thread busy-loops through all queues sleeping 100µs per iteration, consuming 2-3 cores indefinitely. Fixes OpenGene#721 (hangs with --detect_adapter_for_pe on paired-end data, v1.3.6+)
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #721: Hangs during paired-end adapter detection with high worker thread counts (48+) on large FASTQ files.
Root Cause
A regression in v1.3.4 (commit b402d71) removed two critical synchronization signals from the
SingleProducerSingleConsumerListlock-free queue:Missing first-item ready signal (line 109): When the first item is added to an empty queue,
head->nextItemReadyis not explicitly marked as ready. This causescanBeConsumed()to return false even though an item exists, causing consumer threads to block indefinitely.Missing tail-item safety check (line 101): The last item in the queue has no successor, so
nextItemReadyremains false until a second item is produced. Without the(head == tail)safety check,canBeConsumed()returns false for tail items, causing writer threads to stall.With 48+ worker threads and large FASTQ files:
Fix
Restore two critical synchronization signals from the proven v1.3.3 implementation:
|| (head == tail)check incanBeConsumed()to ensure tail items are always consumablehead->nextItemReady.store(true, std::memory_order_release)to signal that the first item is readyValidation
Build Validation
Functional Testing
Logic Verification
Regression Risk Assessment
Testing Recommendations
Before merge:
CXXFLAGS=\"-fsanitize=thread\" makeRelated Issues
🤖 Generated with Claude Code