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

@@ -1369,9 +1369,8 @@ query_getdb(ns_client_t *client, dns_name_t *name, dns_rdatatype_t qtype,
* If # zone labels < # name labels, try to find an even better match
* Only try if DLZ drivers are loaded for this view
*/
if (ISC_UNLIKELY(zonelabels < namelabels &&
!ISC_LIST_EMPTY(client->view->dlz_searched)))
{
if (zonelabels < namelabels &&
!ISC_LIST_EMPTY(client->view->dlz_searched)) {
dns_clientinfomethods_t cm;
dns_clientinfo_t ci;
dns_db_t *tdbp;
@@ -5497,10 +5496,9 @@ ns__query_start(query_ctx_t *qctx) {
result = query_getdb(qctx->client, qctx->client->query.qname,
qctx->qtype, qctx->options, &qctx->zone, &qctx->db,
&qctx->version, &qctx->is_zone);
if (ISC_UNLIKELY((result != ISC_R_SUCCESS || !qctx->is_zone) &&
qctx->qtype == dns_rdatatype_ds &&
!RECURSIONOK(qctx->client) &&
(qctx->options & DNS_GETDB_NOEXACT) != 0))
if ((result != ISC_R_SUCCESS || !qctx->is_zone) &&
qctx->qtype == dns_rdatatype_ds && !RECURSIONOK(qctx->client) &&
(qctx->options & DNS_GETDB_NOEXACT) != 0)
{
/*
* This is a non-recursive QTYPE=DS query with QNAME whose
@@ -5655,7 +5653,7 @@ qctx_prepare_buffers(query_ctx_t *qctx, isc_buffer_t *buffer) {
REQUIRE(buffer != NULL);
qctx->dbuf = ns_client_getnamebuf(qctx->client);
if (ISC_UNLIKELY(qctx->dbuf == NULL)) {
if (qctx->dbuf == NULL) {
CCTRACE(ISC_LOG_ERROR,
"qctx_prepare_buffers: ns_client_getnamebuf "
"failed");
@@ -5663,7 +5661,7 @@ qctx_prepare_buffers(query_ctx_t *qctx, isc_buffer_t *buffer) {
}
qctx->fname = ns_client_newname(qctx->client, qctx->dbuf, buffer);
if (ISC_UNLIKELY(qctx->fname == NULL)) {
if (qctx->fname == NULL) {
CCTRACE(ISC_LOG_ERROR,
"qctx_prepare_buffers: ns_client_newname failed");
@@ -5671,7 +5669,7 @@ qctx_prepare_buffers(query_ctx_t *qctx, isc_buffer_t *buffer) {
}
qctx->rdataset = ns_client_newrdataset(qctx->client);
if (ISC_UNLIKELY(qctx->rdataset == NULL)) {
if (qctx->rdataset == NULL) {
CCTRACE(ISC_LOG_ERROR,
"qctx_prepare_buffers: ns_client_newrdataset failed");
goto error;