mirror of
https://github.com/isc-projects/bind9.git
synced 2026-03-19 09:09:36 -04:00
Use mul and div instead of bitshifts to calculate srtt
There was a microoptimization for smoothing srtt with bitshifts. Revert
the code to use * 98 / 100, it doesn't really make that difference on
modern CPUs, for comparison here:
muldiv:
imul eax, edi, 98
imul rax, rax, 1374389535
shr rax, 37
ret
shift:
mov eax, edi
sal eax, 9
sub eax, edi
shr eax, 9
ret
This commit is contained in:
parent
0635bd01cb
commit
91f3b0edee
1 changed files with 2 additions and 4 deletions
|
|
@ -3052,10 +3052,8 @@ adjustsrtt(dns_adbaddrinfo_t *addr, unsigned int rtt, unsigned int factor,
|
|||
|
||||
if (factor == DNS_ADB_RTTADJAGE) {
|
||||
if (atomic_load(&addr->entry->lastage) != now) {
|
||||
new_srtt = addr->entry->srtt;
|
||||
new_srtt <<= 9;
|
||||
new_srtt -= addr->entry->srtt;
|
||||
new_srtt >>= 9;
|
||||
new_srtt = (uint64_t)atomic_load(&addr->entry->srtt) *
|
||||
98 / 100;
|
||||
atomic_store(&addr->entry->lastage, now);
|
||||
atomic_store(&addr->entry->srtt, new_srtt);
|
||||
addr->srtt = new_srtt;
|
||||
|
|
|
|||
Loading…
Reference in a new issue