mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-27 07:02:11 +00:00
MINOR: ring: keep a few frequently used pointers in the local stack
Code disassembly shows that ring->storage->tail and ring->queue are accessed a lot and reloaded a lot due to aliasing. Let's just have variables for them in the local stack. It makes the code smaller and slightly faster.
This commit is contained in:
parent
c7bd7a68e4
commit
447189f286
@ -173,6 +173,7 @@ void ring_free(struct ring *ring)
|
||||
*/
|
||||
ssize_t ring_write(struct ring *ring, size_t maxlen, const struct ist pfx[], size_t npfx, const struct ist msg[], size_t nmsg)
|
||||
{
|
||||
size_t *tail_ptr = &ring->storage->tail;
|
||||
size_t head_ofs, tail_ofs, new_tail_ofs;
|
||||
size_t ring_size;
|
||||
char *ring_area;
|
||||
@ -239,10 +240,10 @@ ssize_t ring_write(struct ring *ring, size_t maxlen, const struct ist pfx[], siz
|
||||
* change (use it as a ticket).
|
||||
*/
|
||||
while (1) {
|
||||
tail_ofs = HA_ATOMIC_FETCH_OR(&ring->storage->tail, RING_TAIL_LOCK);
|
||||
tail_ofs = HA_ATOMIC_FETCH_OR(tail_ptr, RING_TAIL_LOCK);
|
||||
if (!(tail_ofs & RING_TAIL_LOCK))
|
||||
break;
|
||||
pl_wait_unlock_long(&ring->storage->tail, RING_TAIL_LOCK);
|
||||
pl_wait_unlock_long(tail_ptr, RING_TAIL_LOCK);
|
||||
}
|
||||
|
||||
head_ofs = HA_ATOMIC_LOAD(&ring->storage->head);
|
||||
@ -291,7 +292,7 @@ ssize_t ring_write(struct ring *ring, size_t maxlen, const struct ist pfx[], siz
|
||||
}
|
||||
|
||||
/* and release other writers */
|
||||
HA_ATOMIC_STORE(&ring->storage->tail, new_tail_ofs);
|
||||
HA_ATOMIC_STORE(tail_ptr, new_tail_ofs);
|
||||
|
||||
if (vp_size(v1, v2) > ring_size - needed - 1 - 1) {
|
||||
/* we had to stop due to readers blocking the head,
|
||||
|
Loading…
Reference in New Issue
Block a user