BenLangmead / bowtie2

A fast and sensitive gapped read aligner
GNU General Public License v3.0
638 stars 160 forks source link

-p/--threads option always uses 1 more thread than is specified. #465

Open leowill01 opened 4 months ago

leowill01 commented 4 months ago

when i run bowtie2 and specify the number of threads to use(eg -p 1, -p 4), the amount of CPU usage is always 1 more core in use than is specified by the number of threads to use. for example, if i specify -p 1:

bowtie2 --no-unal -p 1 \
-x 'ref-genome-idx' \
-1 reads-R1_001.fastq.gz \
-2 reads-R2_001.fastq.gz

the cpu usage (via htop) for the process with be at ~200% indicating a usage of 2 threads, not 1:

 CPU% Command
  2.8 └─ /usr/bin/perl5.34 /opt/homebrew/bin/bowtie2 --no-unal -p 1 -x PAO1-- ...
196.0   └─ /opt/homebrew/bin/../Cellar/bowtie2/2.5.2/bin/bowtie2-align-s --w ...

likewise, for any other number of threads, it always uses n+1 CPU cores. for -p 4:

bowtie2 --no-unal -p 4 \
-x 'ref-genome-idx' \
-1 reads-R1_001.fastq.gz \
-2 reads-R2_001.fastq.gz

CPU usage (via htop):

 CPU% Command
  2.4 └─ /usr/bin/perl5.34 /opt/homebrew/bin/bowtie2 --no-unal -p 4 -x
445.4   └─ /opt/homebrew/bin/../Cellar/bowtie2/2.5.2/bin/bowtie2-align

(between 400-500% core usage because i have other jobs running, but bare system it would be ~500% indicating usage of 5 CPU cores)

this is effectively limiting cutting my sample throughput in half because when bowtie2 is in usage with 1 thread specified, every job uses 2 threads instead. is this a bug or a feature? am i missing something?

tested on:

ch4rr0 commented 4 months ago

Hello,

As of bowtie2 v2.5.0 we moved to async model (dedicated thread) for processing I/O. The --threads flag specifies the number of computational (alignment) threads that bowtie2 will use, hence the thread count will always be +1 than the default or the value specified.