[Tarantool-patches] [PATCH] relay: yield explicitly every N sent rows
Cyrill Gorcunov
gorcunov at gmail.com
Sat Feb 13 01:25:59 MSK 2021
On Fri, Feb 12, 2021 at 10:48:49PM +0100, Vladislav Shpilevoy wrote:
> > diff --git a/src/box/relay.cc b/src/box/relay.cc
> > index df04f8198..afc57dfbc 100644
> > --- a/src/box/relay.cc
> > +++ b/src/box/relay.cc
> > @@ -836,11 +836,20 @@ relay_send(struct relay *relay, struct xrow_header *packet)
> > {
> > ERROR_INJECT_YIELD(ERRINJ_RELAY_SEND_DELAY);
> >
> > + static uint64_t row_cnt = 0;
>
> Relays are in threads. So this variable either should be thread-local,
> or be in struct relay. Otherwise you get non-atomic updates which may
> lead to some increments disappearing.
That's the good catch! Without lock/tls this gonna be completely
arbritrary updates.
> Given that thread-local variable access is not free, I would go for
> having it in struct relay, but up to you.
Actually tls access should be as cheap as regular memory access
except using different base register (iirc %fs on linux). But
maybe things are changed novadays.
More information about the Tarantool-patches
mailing list