P-H-C / phc-winner-argon2

The password hash Argon2, winner of PHC
Other
4.78k stars 406 forks source link

Benchmark is using a bad method for time calculation #368

Open vault-thirteen opened 10 months ago

vault-thirteen commented 10 months ago

Usage of RDTSC in C code in the year 2023 has several negative effects.

  1. TSC cannot be relied upon to provide accurate results — unless great care is taken to correct the possible flaws: rate of tick and whether all cores (processors) have identical values in their time-keeping registers. https://en.wikipedia.org/wiki/Time_Stamp_Counter

  2. The RDTSC CPU instruction is supported mostly on CPUs of Intel x86 architecture and their derivatives such as AMD64. This makes benchmarking useless on CPU having following architectures – ARM, MIPS, POWER, RISC-V, SPARC and others. It is also useless on virtual ISA's such as WebAssembly. All this makes the C code unportable.