MCPcopy Create free account
hub / github.com/DFIR-ORC/dfir-orc / ThreadCountForLevel

Function ThreadCountForLevel

src/OrcLib/ZipCreate.cpp:81–96  ·  view source on GitHub ↗

Cap the LZMA2 thread count so peak compression memory no longer scales with the host core count. The encoder splits 'mt' as (block-threads x match-finder-threads); bt4 (Normal and above) uses 2 match-finder threads, so total mt = 2 x block-threads, and block-threads is what multiplies memory. Allow up to 2 block-threads on 64-bit (mt=4) and a single solid block on 32-bit (mt=2) where the address s

Source from the content-addressed store, hash-verified

79// behaviour and keeps peak memory close to a single dictionary.
80// Returns 0 to keep the library default (one thread per processor).
81UInt32 ThreadCountForLevel(ZipCreate::CompressionLevel level)
82{
83 switch (level)
84 {
85 case ZipCreate::Normal:
86 case ZipCreate::Maximum:
87 case ZipCreate::Ultra:
88 {
89 const UInt32 cap = 2u;
90 const UInt32 cores = ProcessorCount();
91 return cores < cap ? cores : cap;
92 }
93 default:
94 return 0;
95 }
96}
97
98void StoreFileHashes(OrcArchive::ArchiveItems& items, bool releaseInputStreams)
99{

Callers 1

SetCompressionLevelMethod · 0.85

Calls 1

ProcessorCountFunction · 0.85

Tested by

no test coverage detected