amplab / snap

Scalable Nucleotide Alignment Program -- a fast and accurate read aligner for high-throughput sequencing data
https://www.microsoft.com/en-us/research/project/snap/
Apache License 2.0
287 stars 66 forks source link

CPU affinity #137

Closed jkbonfield closed 2 years ago

jkbonfield commented 2 years ago

Snap-aligner uses sched_setaffinity with the processor number coming from threadNum. This means for N threads it uses CPU 0 to N-1. At the very least this behaviour would be good to document.

Unfortunately if I run "taskset -c 30,37 snap-aligner -t8" that means it'll (by default) still end up on CPUs 0 to 7. This has had me chasing my tail all afternoon as to why the speed is so variable (on a shared host with batch scheduling allocating CPUs).

I am aware that --b can disable this feature, but it's on by default. Could it call sched_getaffinity first and if not a default mask of all CPUs, disable this feature and honour the environment instead?

bolosky commented 2 years ago

I put a (Linux only) fix for this in the dev branch, in version 1.1dev.1. I'll be in the big 1.1 update when we release it.

If you want to try it out and make sure it works, just build the dev version. You'll need to rebuild your index if you do because we changed the format between 1.0 and 1.1.

I'll close this issue when 1.1 releases.

bolosky commented 2 years ago

Fixed in 2.0.