Open samscott89 opened 7 years ago
This undocumented reporting of CPU instead of real time also makes Argon2 appear to be faster than it actually is under the current system load - which is especially relevant when benchmarking multiple concurrent instances using a script around the supplied argon2
program. With this reporting, it'd appear that running more concurrent instances than there are logical CPUs in the system produces higher cumulative speed, but this is of course not true.
The program should say "seconds of CPU time" or the like (not just "seconds"), or alternatively the uses of clock()
would need to be replaced with times()
(its return value is real time, even though it reports CPU times in the supplied structure, which we don't have to use) and CLOCKS_PER_SEC
with sysconf(_SC_CLK_TCK)
(not CLK_TCK
, which on modern systems might be undefined or wrong). Better yet, both real and CPU times could be reported (with the latter obtained by summing the fields returned by times()
then since we'd be calling it anyway, and we'd cache sysconf(_SC_CLK_TCK)
in a variable since it'd be used multiple times), with clear wording.
This is because benchmark is using the RDTSC
CPU instruction. Time calculation should be performed by the environmental code (by an O.S. calling this library), not by the library's low-level C code itself.
Also see this: https://github.com/P-H-C/phc-winner-argon2/issues/368
@vault-thirteen No, that's a separate issue. This one is about the CPU time reporting vs. users' expectations of real time being reported. The readings for this are obtained from the OS, via clock()
. The code also uses RDTSC
for other reporting, but this issue isn't about that.
Hi,
Just a note that currently the benchmark timings (and similarly the output of the CLI tool) are perhaps a bit confusing, by reporting the CPU time instead of wall.
This is probably intentional, but there could perhaps be a note somewhere, or an option to display both.
For example:
From which it appears as though it takes longer with more threads. When the actual wall time is significantly shorter: