By default, kraken2 loads its database into process-local RAM for every invocation, which requires substantial amount of time. Repeating this for many samples (*mhm* especially with the better db - Pracken (>400 GB)) the time to classify samples explodes, just because of repeated db-loading from scratch.
Use –memory-mapping to access the database through file-backed memory mapping instead of copying the entire index into each process's RAM. The operating system can reuse cached database pages between samples1), reducing repeated loading overhead.
e.g.
kraken2 \ --db /mnt/nas1/db/kraken/pracken_20260708/ \ --paired \ --gzip-compressed \ --threads 8 \ --confidence 0.1 \ --use-names \ --memory-mapping \ --report sample_report.txt \ --output sample_output.txt \ sample_R1.fastq.gz sample_R2.fastq.gz
Example Kraken2 Script:
References:
–memory-mapping does.