Skip to content

Detect count of logical cores instead of physical #2071

@mako2580

Description

@mako2580

Describe the bug
Parameter -T0 is detecting physical cores, but I think it should be detecting logical cores instead, to take advantage of hyperthreading.

To Reproduce
Steps to reproduce the behavior:

  1. Download data from http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia and convert zip to tar
  2. Run zstd with parameter -T0
  3. Rerun zstd with parameter -T#ofLogicalCores

Expected behavior
zstd should use all logical cores to speed up compression.

Screenshots and charts
As you can see from data below, parameter -T0 is the same as -T2, which is number of physical cores, which is expectable from source code. Only on default compression level 3 is using only number of physical cores faster than number of logical cores, but on any other compression level situation change. And with higher compression level the speed up is more visible.

Compression level 2:

$ time zstd -2 -f -T0 silesia.tar -o silesia.tar.zst
silesia.tar          : 32.88%   (211957760 => 69684920 bytes, silesia.tar.zst) 

real    0m0.761s
user    0m1.444s
sys     0m0.134s
$ time zstd -2 -f -T2 silesia.tar -o silesia.tar.zst
silesia.tar          : 32.88%   (211957760 => 69684920 bytes, silesia.tar.zst) 

real    0m0.754s
user    0m1.480s
sys     0m0.113s
$ time zstd -2 -f -T4 silesia.tar -o silesia.tar.zst
silesia.tar          : 32.88%   (211957760 => 69684920 bytes, silesia.tar.zst) 

real    0m0.732s
user    0m2.393s
sys     0m0.148s

Compression level 3:

$ time zstd -3 -f -T0 silesia.tar -o silesia.tar.zst
silesia.tar          : 31.47%   (211957760 => 66713509 bytes, silesia.tar.zst) 

real    0m1.273s
user    0m2.437s
sys     0m0.110s
$ time zstd -3 -f -T2 silesia.tar -o silesia.tar.zst
silesia.tar          : 31.47%   (211957760 => 66713509 bytes, silesia.tar.zst) 

real    0m1.282s
user    0m2.423s
sys     0m0.159s
$ time zstd -3 -f -T4 silesia.tar -o silesia.tar.zst
silesia.tar          : 31.47%   (211957760 => 66713509 bytes, silesia.tar.zst) 

real    0m1.389s
user    0m4.698s
sys     0m0.156s

Compression level 4:

$ time zstd -4 -f -T0 silesia.tar -o silesia.tar.zst
silesia.tar          : 30.94%   (211957760 => 65572880 bytes, silesia.tar.zst) 

real    0m1.882s
user    0m3.659s
sys     0m0.139s
$ time zstd -4 -f -T2 silesia.tar -o silesia.tar.zst
silesia.tar          : 30.94%   (211957760 => 65572880 bytes, silesia.tar.zst) 

real    0m1.906s
user    0m3.638s
sys     0m0.168s
$ time zstd -4 -f -T4 silesia.tar -o silesia.tar.zst
silesia.tar          : 30.94%   (211957760 => 65572880 bytes, silesia.tar.zst) 

real    0m1.810s
user    0m6.132s
sys     0m0.162s

Compression level 10:

$ time zstd -10 -f -T0 silesia.tar -o silesia.tar.zst
silesia.tar          : 28.11%   (211957760 => 59582278 bytes, silesia.tar.zst) 

real    0m10.516s
user    0m19.922s
sys     0m0.179s
$ time zstd -10 -f -T2 silesia.tar -o silesia.tar.zst
silesia.tar          : 28.11%   (211957760 => 59582278 bytes, silesia.tar.zst) 

real    0m10.571s
user    0m20.508s
sys     0m0.186s
$ time zstd -10 -f -T4 silesia.tar -o silesia.tar.zst
silesia.tar          : 28.11%   (211957760 => 59582278 bytes, silesia.tar.zst) 

real    0m8.313s
user    0m28.980s
sys     0m0.205s

Desktop:

  • OS: Arch Linux
  • Version Rolling release
  • Compiler gcc
  • Flags: not sure - used default package from distribution and not relevant to bug
  • Other relevant hardware specs Intel i5 4200U - 2 physical cores and 4 logical cores
  • Build system Makefile

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions