Skip to content

Conversation

@sergey-dryabzhinsky
Copy link
Contributor

@sergey-dryabzhinsky sergey-dryabzhinsky commented Oct 18, 2025

cpu cores even in lxc containers
Address issue #4510

@meta-cla meta-cla bot added the CLA Signed label Oct 18, 2025
@sergey-dryabzhinsky
Copy link
Contributor Author

sergey-dryabzhinsky commented Oct 18, 2025

Backup compression on proxmox3 server / debian7. Cpu: intel core i7 6850k 3.6 GHz, 12 cores.
W/o patch:

 time zstdmt -14 -vv -f vzdump-openvz-20001-2025_10_09-15_57_53.tar
*** Zstandard CLI (64-bit) v1.5.7, by Yann Collet ***
Note: 6 physical core(s) detected
Compressing with 6 worker threads
--zstd=wlog=22,clog=22,hlog=23,slog=5,mml=5,tlen=32,strat=6
--format=.zst --no-sparse --block-size=0 --memory=134217728 --threads=6 --content-size
Decompression will require 4194304 B of memory
vzdump-openvz-20001-2025_10_09-15_57_53.tar : 22.04%   (1803284480 B => 397499354 B, vzdump-openvz-20001-20
25_10_09-15_57_53.tar.zst)
vzdump-openvz-20001-2025_10_09-15_57_53.tar : Completed in 26.51 sec  (cpu load : 489%)
real    0m26.573s
user    2m8.388s
sys     0m1.313s

@sergey-dryabzhinsky
Copy link
Contributor Author

With patch:

time zstdmt -14 -vv -f vzdump-openvz-20001-2025_10_09-15_57_53.tar
*** Zstandard CLI (64-bit) v1.5.7, by Yann Collet ***
Note: 12 physical core(s) detected
Compressing with 12 worker threads
--zstd=wlog=22,clog=22,hlog=23,slog=5,mml=5,tlen=32,strat=6
--format=.zst --no-sparse --block-size=0 --memory=134217728 --threads=12 --content-size
Decompression will require 4194304 B of memory
vzdump-openvz-20001-2025_10_09-15_57_53.tar : 22.04%   (1803284480 B => 397499354 B, vzdump-openvz-20001-2025_10_09-15_57_53.tar.zst)
vzdump-openvz-20001-2025_10_09-15_57_53.tar : Completed in 17.84 sec  (cpu load : 916%)
real    0m17.990s
user    2m42.266s
sys     0m1.353s

System load greater but process run faster.

@sergey-dryabzhinsky
Copy link
Contributor Author

sergey-dryabzhinsky commented Oct 18, 2025

Second server: proxmox7, debian11, cpu intel xeon E3-1230 v6 @ 3.50GHz, 8 cores.
W/o patch:

 time zstdmt -14 -vv -f vzdump-openvz-60047-2023_08_18-18_01_53.tar
*** Zstandard CLI (64-bit) v1.5.5, by Yann Collet ***
Note: 4 physical core(s) detected
--zstd=wlog=22,clog=22,hlog=23,slog=5,mml=5,tlen=32,strat=6
--format=.zst --no-sparse --block-size=0 --memory=134217728 --threads=4 --content-size
Decompression will require 4194304 B of memory
vzdump-openvz-60047-2023_08_18-18_01_53.tar : 25.32%   (580116480 B => 146903865 B, vzdump-openvz-60047-2023_08_18-18_01_53.tar.zst)
vzdump-openvz-60047-2023_08_18-18_01_53.tar : Completed in 12.85 sec  (cpu load : 375%)
real    0m12.890s
user    0m47.804s
sys     0m0.433s

@sergey-dryabzhinsky
Copy link
Contributor Author

sergey-dryabzhinsky commented Oct 18, 2025

With patch:

time zstdmt -14 -vv -f vzdump-openvz-60047-2023_08_18-18_01_53.tar
*** Zstandard CLI (64-bit) v1.5.7, by Yann Collet ***
Note: 8 physical core(s) detected
Compressing with 8 worker threads
--zstd=wlog=22,clog=22,hlog=23,slog=5,mml=5,tlen=32,strat=6
--format=.zst --no-sparse --block-size=0 --memory=134217728 --threads=8 --content-size
Decompression will require 4194304 B of memory
vzdump-openvz-60047-2023_08_18-18_01_53.tar : 25.01%   (580116480 B => 145070412 B, vzdump-openvz-60047-2023_08_18-18_01_53.tar.zst)
vzdump-openvz-60047-2023_08_18-18_01_53.tar : Completed in 9.25 sec  (cpu load : 673%)
real    0m9.279s
user    1m1.568s
sys     0m0.703s

@sergey-dryabzhinsky
Copy link
Contributor Author

Failed action not related

@Cyan4973
Copy link
Contributor

If you prefer zstdmt or -T0 to count logical cores as opposed to physical ones, there is already the --auto-threads=logical command.

@sergey-dryabzhinsky
Copy link
Contributor Author

@Cyan4973 Thanx, I'll check it

@sergey-dryabzhinsky
Copy link
Contributor Author

That works:

 zstdmt -vv --auto-threads=logical /dev/zero
*** Zstandard CLI (64-bit) v1.5.7, by Yann Collet ***
Note: 8 logical core(s) detected
Compressing with 8 worker threads
--zstd=wlog=21,clog=16,hlog=17,slog=1,mml=5,tlen=0,strat=2
--format=.zst --no-sparse --block-size=0 --memory=134217728 --threads=8 --content-size
zstd: /dev/zero is not a regular file -- ignored

Question: why it is not default behaviour?

@Cyan4973
Copy link
Contributor

It's a question of choice.
The original choice was: one thread per physical code.
I already explained in another thread the reasoning leading to that choice.

Now, this is not immutable, we could change it if we feel that's a better option.
This is less a question of code than a question of properly documenting why a different default would be better.

@sergey-dryabzhinsky
Copy link
Contributor Author

Maybe this behaviour could be changed at compile time to let distributors choose what they want?

@Cyan4973
Copy link
Contributor

Maybe this behaviour could be changed at compile time to let distributors choose what they want?

A compilation variable would do the trick

Adx new defined compile var
Use new defined var to enable-disable hardcode
Add comments
Fix comment
@sergey-dryabzhinsky
Copy link
Contributor Author

sergey-dryabzhinsky commented Nov 5, 2025

I added compilation "variable" through cflags -DZSTD_PARSE_FULL_CPUINFO , so my code stay disabled by default. I'll add other PR with another compile var later

@sergey-dryabzhinsky
Copy link
Contributor Author

Work still in progress.

@sergey-dryabzhinsky sergey-dryabzhinsky changed the title Count line of processor in /proc/cpuinfo on linux, that matches [WIP] Count line of processor in /proc/cpuinfo on linux, that matches... Nov 6, 2025
Change var name
Fixed prepocessor check on new var
@sergey-dryabzhinsky
Copy link
Contributor Author

All done I think.

@sergey-dryabzhinsky sergey-dryabzhinsky changed the title [WIP] Count line of processor in /proc/cpuinfo on linux, that matches... Count line of processor in /proc/cpuinfo on linux, that matches... Nov 6, 2025
@sergey-dryabzhinsky
Copy link
Contributor Author

Not shure how to add this to docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants