mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-10 00:57:02 +02:00
MINOR: peers: Optimization for dictionary cache lookup.
When we look up an dictionary entry in the cache used upon transmission we store the last result in ->prev_lookup of struct dcache_tx so that to compare it with the subsequent entries to look up and save performances.
This commit is contained in:
parent
fd827937ed
commit
b65717fa55
@ -102,6 +102,8 @@ struct dcache_tx {
|
||||
unsigned int lru_key;
|
||||
/* An array of entries to store pointers to dictionary entries. */
|
||||
struct ebpt_node *entries;
|
||||
/* The previous lookup result. */
|
||||
struct ebpt_node *prev_lookup;
|
||||
/* ebtree to store the previous entries. */
|
||||
struct eb_root cached_entries;
|
||||
};
|
||||
|
15
src/peers.c
15
src/peers.c
@ -2849,6 +2849,7 @@ static struct dcache_tx *new_dcache_tx(size_t max_entries)
|
||||
goto err;
|
||||
|
||||
d->lru_key = 0;
|
||||
d->prev_lookup = NULL;
|
||||
d->cached_entries = EB_ROOT_UNIQUE;
|
||||
d->entries = entries;
|
||||
|
||||
@ -2948,7 +2949,17 @@ static struct ebpt_node *dcache_tx_insert(struct dcache *dc, struct dcache_tx_en
|
||||
struct ebpt_node *o;
|
||||
|
||||
dc_tx = dc->tx;
|
||||
o = dcache_tx_lookup_value(dc_tx, i);
|
||||
|
||||
if (dc_tx->prev_lookup && dc_tx->prev_lookup->key == i->entry.key) {
|
||||
o = dc_tx->prev_lookup;
|
||||
} else {
|
||||
o = dcache_tx_lookup_value(dc_tx, i);
|
||||
if (o) {
|
||||
/* Save it */
|
||||
dc_tx->prev_lookup = o;
|
||||
}
|
||||
}
|
||||
|
||||
if (o) {
|
||||
/* Copy the ID. */
|
||||
i->id = o - dc->tx->entries;
|
||||
@ -2956,7 +2967,7 @@ static struct ebpt_node *dcache_tx_insert(struct dcache *dc, struct dcache_tx_en
|
||||
}
|
||||
|
||||
/* The new entry to put in cache */
|
||||
o = &dc_tx->entries[dc_tx->lru_key];
|
||||
dc_tx->prev_lookup = o = &dc_tx->entries[dc_tx->lru_key];
|
||||
|
||||
ebpt_delete(o);
|
||||
o->key = i->entry.key;
|
||||
|
Loading…
Reference in New Issue
Block a user