Optimize system_time function

The uint128 code does not optimize as well as expected. Since this
function can be called quite often, use a more optimal implementation
(quite similar to what we had for x86_64 before refactoring).

Unfortunately this is still not as good as the hand-optimized assembler
previously used for 32bit x86, unless compiled with clang, where it gets
pretty close.
This commit is contained in:
X512
2020-01-26 14:48:30 +01:00
committed by Adrien Destugues
parent d6a742cafd
commit 7512485b94
+4 -2
View File
@@ -304,8 +304,10 @@ slower_sample:
extern "C" bigtime_t
system_time()
{
uint128 tsc(rdtsc());
return uint64((tsc * gTimeConversionFactor) >> 32);
uint64 tsc = rdtsc();
uint64 lo = (uint32)tsc;
uint64 hi = tsc >> 32;
return ((lo * gTimeConversionFactor) >> 32) + hi * gTimeConversionFactor;
}