[Tarantool-patches] [PATCH] relay: yield explicitly every N sent rows
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Thu Feb 18 00:11:04 MSK 2021
Hi! Thanks for the fixes!
> diff --git a/src/box/relay.cc b/src/box/relay.cc
> index 1d8edf116..6d9269e1d 100644
> --- a/src/box/relay.cc
> +++ b/src/box/relay.cc
> @@ -117,6 +117,11 @@ struct relay {
> * is passed by the replica on subscribe.
> */
> uint32_t id_filter;
> + /**
> + * How many rows has this relay sent to the replica. Used to yield once
> + * in a while when reading a WAL to unblock the event loop.
> + */
> + size_t row_cnt;
1. But it is not a size of anything, right? Maybe make it
int64_t then?
> @@ -846,7 +851,7 @@ relay_send(struct relay *relay, struct xrow_header *packet)
> * It may happen that the socket is always ready for write, so yield
> * explicitly every now and then to not block the event loop.
> */
> - if (++row_cnt % WAL_ROWS_PER_YIELD == 0)
> + if (++relay->row_cnt % WAL_ROWS_PER_YIELD == 0)
2. I just found WAL_ROWS_PER_YIELD is not a power of 2. This means
'%' may be expensive. If WAL_ROWS_PER_YIELD would be a power of 2,
'%' would be turned by the compiler into '&' to cut the remainder off.
Maybe worth changing in a separate non-related to this bug commit?
More information about the Tarantool-patches
mailing list