mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 21:31:28 +02:00
IMPORT: eb32/eb64: place an unlikely() on the leaf test
In the loop we can help the compiler build slightly more efficient code by placing an unlikely() around the leaf test. This shows a consistent 0.5% performance gain both on eb32 and eb64. This is ebtree commit 6c9cdbda496837bac1e0738c14e42faa0d1b92c4.
This commit is contained in:
parent
384907f4e7
commit
6c54bf7295
@ -126,7 +126,7 @@ static forceinline struct eb32_node *__eb32_lookup(struct eb_root *root, u32 x)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if ((eb_gettag(troot) == EB_LEAF)) {
|
if (unlikely(eb_gettag(troot) == EB_LEAF)) {
|
||||||
node = container_of(eb_untag(troot, EB_LEAF),
|
node = container_of(eb_untag(troot, EB_LEAF),
|
||||||
struct eb32_node, node.branches);
|
struct eb32_node, node.branches);
|
||||||
if (node->key == x)
|
if (node->key == x)
|
||||||
@ -180,7 +180,7 @@ static forceinline struct eb32_node *__eb32i_lookup(struct eb_root *root, s32 x)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if ((eb_gettag(troot) == EB_LEAF)) {
|
if (unlikely(eb_gettag(troot) == EB_LEAF)) {
|
||||||
node = container_of(eb_untag(troot, EB_LEAF),
|
node = container_of(eb_untag(troot, EB_LEAF),
|
||||||
struct eb32_node, node.branches);
|
struct eb32_node, node.branches);
|
||||||
if (node->key == (u32)x)
|
if (node->key == (u32)x)
|
||||||
|
@ -126,7 +126,7 @@ static forceinline struct eb64_node *__eb64_lookup(struct eb_root *root, u64 x)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if ((eb_gettag(troot) == EB_LEAF)) {
|
if (unlikely(eb_gettag(troot) == EB_LEAF)) {
|
||||||
node = container_of(eb_untag(troot, EB_LEAF),
|
node = container_of(eb_untag(troot, EB_LEAF),
|
||||||
struct eb64_node, node.branches);
|
struct eb64_node, node.branches);
|
||||||
if (node->key == x)
|
if (node->key == x)
|
||||||
@ -180,7 +180,7 @@ static forceinline struct eb64_node *__eb64i_lookup(struct eb_root *root, s64 x)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if ((eb_gettag(troot) == EB_LEAF)) {
|
if (unlikely(eb_gettag(troot) == EB_LEAF)) {
|
||||||
node = container_of(eb_untag(troot, EB_LEAF),
|
node = container_of(eb_untag(troot, EB_LEAF),
|
||||||
struct eb64_node, node.branches);
|
struct eb64_node, node.branches);
|
||||||
if (node->key == (u64)x)
|
if (node->key == (u64)x)
|
||||||
|
@ -57,7 +57,7 @@ struct eb32_node *eb32_lookup_le(struct eb_root *root, u32 x)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if ((eb_gettag(troot) == EB_LEAF)) {
|
if (unlikely(eb_gettag(troot) == EB_LEAF)) {
|
||||||
/* We reached a leaf, which means that the whole upper
|
/* We reached a leaf, which means that the whole upper
|
||||||
* parts were common. We will return either the current
|
* parts were common. We will return either the current
|
||||||
* node or its next one if the former is too small.
|
* node or its next one if the former is too small.
|
||||||
@ -152,7 +152,7 @@ struct eb32_node *eb32_lookup_ge(struct eb_root *root, u32 x)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if ((eb_gettag(troot) == EB_LEAF)) {
|
if (unlikely(eb_gettag(troot) == EB_LEAF)) {
|
||||||
/* We reached a leaf, which means that the whole upper
|
/* We reached a leaf, which means that the whole upper
|
||||||
* parts were common. We will return either the current
|
* parts were common. We will return either the current
|
||||||
* node or its next one if the former is too small.
|
* node or its next one if the former is too small.
|
||||||
|
@ -57,7 +57,7 @@ struct eb64_node *eb64_lookup_le(struct eb_root *root, u64 x)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if ((eb_gettag(troot) == EB_LEAF)) {
|
if (unlikely(eb_gettag(troot) == EB_LEAF)) {
|
||||||
/* We reached a leaf, which means that the whole upper
|
/* We reached a leaf, which means that the whole upper
|
||||||
* parts were common. We will return either the current
|
* parts were common. We will return either the current
|
||||||
* node or its next one if the former is too small.
|
* node or its next one if the former is too small.
|
||||||
@ -152,7 +152,7 @@ struct eb64_node *eb64_lookup_ge(struct eb_root *root, u64 x)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if ((eb_gettag(troot) == EB_LEAF)) {
|
if (unlikely(eb_gettag(troot) == EB_LEAF)) {
|
||||||
/* We reached a leaf, which means that the whole upper
|
/* We reached a leaf, which means that the whole upper
|
||||||
* parts were common. We will return either the current
|
* parts were common. We will return either the current
|
||||||
* node or its next one if the former is too small.
|
* node or its next one if the former is too small.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user