Function blake2b_simd::many::degree [−][src]
pub fn degree() -> usize
Expand description
The parallelism degree of the implementation, detected at runtime. If you
hash your inputs in small batches, making the batch size a multiple of
degree
will generally give good performance.
For example, an x86 processor that supports AVX2 can compute four BLAKE2b
hashes in parallel, so degree
returns 4 on that machine. If you call
hash_many
with only three inputs, that’s not enough to use the AVX2
implementation, and your average throughput will be lower. Likewise if you
call it with five inputs of equal length, the first four will be hashed in
parallel with AVX2, but the last one will have to be hashed by itself, and
again your average throughput will be lower.
As noted in the module level docs, performance is more complicated if your inputs are of different lengths. When parallelizing long and short inputs together, the longer ones will have bytes left over, and the implementation will try to parallelize those leftover bytes with subsequent inputs. The more inputs available in that case, the more the implementation will be able to parallelize.
If you need a constant batch size, for example to collect inputs in an
array, see MAX_DEGREE
.