2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-01 06:55:30 +00:00

Stop providing branch prediction information

The __builtin_expect() can be used to provide the compiler with branch
prediction information.  The Gcc manual says[1] on the subject:

    In general, you should prefer to use actual profile feedback for
    this (-fprofile-arcs), as programmers are notoriously bad at
    predicting how their programs actually perform.

Stop using __builtin_expect() and ISC_LIKELY() and ISC_UNLIKELY() macros
to provide the branch prediction information as the performance testing
shows that named performs better when the __builtin_expect() is not
being used.

1. https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fexpect
This commit is contained in:
Ondřej Surý
2021-10-14 10:33:24 +02:00
parent 80fedf9231
commit e603983ec9
25 changed files with 114 additions and 180 deletions

View File

@@ -227,7 +227,7 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
REQUIRE(dns_name_isabsolute(name));
REQUIRE(offset != NULL);
if (ISC_UNLIKELY((cctx->allowed & DNS_COMPRESS_ENABLED) == 0)) {
if ((cctx->allowed & DNS_COMPRESS_ENABLED) == 0) {
return (false);
}
@@ -256,16 +256,14 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
*/
ch = p[1];
i = tableindex[ch];
if (ISC_LIKELY((cctx->allowed & DNS_COMPRESS_CASESENSITIVE) !=
0)) {
if ((cctx->allowed & DNS_COMPRESS_CASESENSITIVE) != 0) {
for (node = cctx->table[i]; node != NULL;
node = node->next) {
if (ISC_UNLIKELY(node->name.length != length)) {
if (node->name.length != length) {
continue;
}
if (ISC_LIKELY(memcmp(node->name.ndata, p,
length) == 0)) {
if (memcmp(node->name.ndata, p, length) == 0) {
goto found;
}
}
@@ -276,18 +274,18 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
unsigned char c;
unsigned char *label1, *label2;
if (ISC_UNLIKELY(node->name.length != length)) {
if (node->name.length != length) {
continue;
}
l = labels - n;
if (ISC_UNLIKELY(node->name.labels != l)) {
if (node->name.labels != l) {
continue;
}
label1 = node->name.ndata;
label2 = p;
while (ISC_LIKELY(l-- > 0)) {
while (l-- > 0) {
count = *label1++;
if (count != *label2++) {
goto cont1;
@@ -297,7 +295,7 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
INSIST(count <= 63);
/* Loop unrolled for performance */
while (ISC_LIKELY(count > 3)) {
while (count > 3) {
c = maptolower[label1[0]];
if (c != maptolower[label2[0]])
{
@@ -322,7 +320,7 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
label1 += 4;
label2 += 4;
}
while (ISC_LIKELY(count-- > 0)) {
while (count-- > 0) {
c = maptolower[*label1++];
if (c != maptolower[*label2++])
{
@@ -388,7 +386,7 @@ dns_compress_add(dns_compress_t *cctx, const dns_name_t *name,
REQUIRE(VALID_CCTX(cctx));
REQUIRE(dns_name_isabsolute(name));
if (ISC_UNLIKELY((cctx->allowed & DNS_COMPRESS_ENABLED) == 0)) {
if ((cctx->allowed & DNS_COMPRESS_ENABLED) == 0) {
return;
}
@@ -489,7 +487,7 @@ dns_compress_rollback(dns_compress_t *cctx, uint16_t offset) {
REQUIRE(VALID_CCTX(cctx));
if (ISC_UNLIKELY((cctx->allowed & DNS_COMPRESS_ENABLED) == 0)) {
if ((cctx->allowed & DNS_COMPRESS_ENABLED) == 0) {
return;
}