2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-01 23:25:38 +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

@@ -292,7 +292,7 @@ void
isc__buffer_putuint8(isc_buffer_t *b, uint8_t val) {
isc_result_t result;
REQUIRE(ISC_BUFFER_VALID(b));
if (ISC_UNLIKELY(b->autore)) {
if (b->autore) {
result = isc_buffer_reserve(&b, 1);
REQUIRE(result == ISC_R_SUCCESS);
}
@@ -326,7 +326,7 @@ void
isc__buffer_putuint16(isc_buffer_t *b, uint16_t val) {
isc_result_t result;
REQUIRE(ISC_BUFFER_VALID(b));
if (ISC_UNLIKELY(b->autore)) {
if (b->autore) {
result = isc_buffer_reserve(&b, 2);
REQUIRE(result == ISC_R_SUCCESS);
}
@@ -339,7 +339,7 @@ void
isc__buffer_putuint24(isc_buffer_t *b, uint32_t val) {
isc_result_t result;
REQUIRE(ISC_BUFFER_VALID(b));
if (ISC_UNLIKELY(b->autore)) {
if (b->autore) {
result = isc_buffer_reserve(&b, 3);
REQUIRE(result == ISC_R_SUCCESS);
}
@@ -375,7 +375,7 @@ void
isc__buffer_putuint32(isc_buffer_t *b, uint32_t val) {
isc_result_t result;
REQUIRE(ISC_BUFFER_VALID(b));
if (ISC_UNLIKELY(b->autore)) {
if (b->autore) {
result = isc_buffer_reserve(&b, 4);
REQUIRE(result == ISC_R_SUCCESS);
}
@@ -416,7 +416,7 @@ isc__buffer_putuint48(isc_buffer_t *b, uint64_t val) {
uint32_t vallo;
REQUIRE(ISC_BUFFER_VALID(b));
if (ISC_UNLIKELY(b->autore)) {
if (b->autore) {
result = isc_buffer_reserve(&b, 6);
REQUIRE(result == ISC_R_SUCCESS);
}
@@ -433,7 +433,7 @@ isc__buffer_putmem(isc_buffer_t *b, const unsigned char *base,
unsigned int length) {
isc_result_t result;
REQUIRE(ISC_BUFFER_VALID(b));
if (ISC_UNLIKELY(b->autore)) {
if (b->autore) {
result = isc_buffer_reserve(&b, length);
REQUIRE(result == ISC_R_SUCCESS);
}
@@ -455,7 +455,7 @@ isc__buffer_putstr(isc_buffer_t *b, const char *source) {
* Do not use ISC__BUFFER_PUTSTR(), so strlen is only done once.
*/
l = strlen(source);
if (ISC_UNLIKELY(b->autore)) {
if (b->autore) {
result = isc_buffer_reserve(&b, l);
REQUIRE(result == ISC_R_SUCCESS);
}
@@ -478,7 +478,7 @@ isc_buffer_putdecint(isc_buffer_t *b, int64_t v) {
/* xxxwpk do it more low-level way ? */
l = snprintf(buf, 21, "%" PRId64, v);
RUNTIME_CHECK(l <= 21);
if (ISC_UNLIKELY(b->autore)) {
if (b->autore) {
result = isc_buffer_reserve(&b, l);
REQUIRE(result == ISC_R_SUCCESS);
}
@@ -515,7 +515,7 @@ isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r) {
REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(r != NULL);
if (ISC_UNLIKELY(b->autore)) {
if (b->autore) {
result = isc_buffer_reserve(&b, r->length);
if (result != ISC_R_SUCCESS) {
return (result);
@@ -623,7 +623,7 @@ isc_buffer_printf(isc_buffer_t *b, const char *format, ...) {
return (ISC_R_FAILURE);
}
if (ISC_UNLIKELY(b->autore)) {
if (b->autore) {
result = isc_buffer_reserve(&b, n + 1);
if (result != ISC_R_SUCCESS) {
return (result);