线程也不是越多越好,多少是好?

前面我们评估了不同大小基因组构建索引所需的计算资源和时间资源和不同大小数据集比对所需的计算资源和时间资源 。
【线程也不是越多越好,多少是好?】下面我们进一步看下不同线程数的影响 。
测试电脑配置

  1. 这是一个10核、20线程的处理器,主频2.8 G HZ,可超频到5.2 GhZ 。
  2. 在windows系统上安装了Ubuntu子系统进行的测试 。

线程也不是越多越好,多少是好?

文章插图
 

线程也不是越多越好,多少是好?

文章插图
 
测试指定不同线程数对速度提升的影响因为测试电脑是最多20线程,这里指定1-25共25个测试线程,程序如下:
# 10核心 20 线程for thread in `seq 1 25`; do i=SRR1039517mkdir -p ${i}/usr/bin/time -v -o star.${i}.thread${thread}.log STAR --runMode alignReads--runThreadN ${thread}--readFilesIn ${i}_1.fastq.gz ${i}_2.fastq.gz--readFilesCommand zcat --genomeDir star_GRCh38--outFileNamePrefix ${i}/${i}. --outFilterType BySJout --outSAMattributes NH HI AS NM MD--outFilterMultimapNmax 20 --alignSJoverhangMin 8 --alignSJDBoverhangMin 1--alignIntronMin 20 --alignIntronMax 1000000--alignMatesGapMax 1000000--outFilterMatchNminOverLread 0.66 --outFilterScoreMinOverLread 0.66--winAnchorMultimapNmax 70 --seedSearchStartLmax 45--outSAMattrIHstart 0 --outSAMstrandField intronMotif--genomeLoad LoadAndKeep--outTmpDir /tmp/${i}/--outSAMtype BAM Unsorted --quantMode GeneCountsdu -s ${i} | awk 'BEGIN{OFS="t"}{print "Output_size: "$1/10^6}' >>star.${i}.thread${thread}.logdone运行完成后,整理所需的计算资源和时间资源数据 。
/bin/rm -f GRCh38_39517_star_reads_map_thread.summaryi=SRR1039517for thread in `seq 1 25`; do echo ${thread} |awk 'BEGIN{OFS="t"}{print "nThreads"; print $1}' |awk -v outputHeader=${thread} -f ./timeIntegrate2.awk - star.${i}.thread${thread}.log>>GRCh38_39517_star_reads_map_thread.summarydone汇总后的数据如下:
Time_costMemory_costnCPUOutput_sizenThreads25.96228.90480.985.58423113.9829.3111.975.5842429.9521729.51762.935.5842537.7703329.72213.855.5842646.35629.92664.785.5842855.158530.13115.615.5842264.6923330.33566.375.5842674.5130.54016.695.5842984.3968330.74456.945.5842394.3801730.9496.995.58426104.4123331.15356.995.58424114.4533331.3586.945.58424124.4103331.56246.955.58429134.4426731.76696.885.58428144.459531.97146.875.58426154.5056732.08596.855.58424164.45832.26396.925.58429174.4641732.48026.865.58428184.49732.64876.915.58425194.442532.84896.955.58426204.4681732.99276.925.5843214.455533.17386.975.58426224.4548333.36756.945.58426234.4613333.54996.995.58428244.4273333.71436.995.5842625STAR比对的时间随指定的线程数的变化
  1. 在给定的线程数少于10个时,随着线程数增加时间逐渐减少,尤其是在线程数从1-6的过程中,下降幅度更明显 。
  2. 线程也不是越多越好,给定多于10个进程对速度提升基本没有贡献 。
  3. (因为测试电脑只有10个核心,不知道这里的节点10是否是受此影响;
  4. 还需要后续在服务器更多测试来判断;
  5. 如果是这样,对我们的指导是设定的线程数不应该超过CPU的核心数 。

线程也不是越多越好,多少是好?

文章插图
 
library(ImageGP) 、sp_scatterplot(“GRCh38_39517_star_reads_map_thread.summary”, melted = T, xvariable = “nThreads”,               yvariable = “Time_cost”, smooth_method = “auto”,               x_label =”Number of specified threads”, y_label = “Running time (minutes)”) +  scale_x_continuous(breaks=seq(1,25, by=1)) +  scale_y_continuous(breaks=seq(1,25, by=1))STAR比对所需内存随指定的线程数的变化
  1. 线程数越多,内存需求越大;
  2. 但整体相差不大 。

线程也不是越多越好,多少是好?

文章插图
 
# 这时绘图要注意,是否加limits=c(0,34)图给人的第一印象不同 。sp_scatterplot("GRCh38_39517_star_reads_map_thread.summary", melted = T, xvariable = "nThreads",yvariable = "Memory_cost", smooth_method = "auto",x_label ="Number of specified threads", y_label = "Maximum physical memory required (Gb)") +scale_x_continuous(breaks=seq(1,25, by=1)) +scale_y_continuous(breaks=seq(1,34, by=1),limits=c(0,34))不加limits=c(0,34)的效果 。是不是感觉内存变化很大???
线程也不是越多越好,多少是好?


推荐阅读