[Tarantool-patches] [PATCH] relay: yield explicitly every N sent rows
Cyrill Gorcunov
gorcunov at gmail.com
Fri Feb 12 14:37:48 MSK 2021
On Fri, Feb 12, 2021 at 02:25:41PM +0300, Serge Petrenko wrote:
> @@ -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;
> packet->sync = relay->sync;
> relay->last_row_time = ev_monotonic_now(loop());
> coio_write_xrow(&relay->io, packet);
> fiber_gc();
>
> + /*
> + * It may happen that the socket is always ready for write, so yield
> + * explicitly every now and then to not block the event loop.
> + */
> + row_cnt++;
> + if (row_cnt % WAL_ROWS_PER_YIELD == 0) {
> + fiber_sleep(0);
> + }
Serge, if I'm not missing something obvious, this row counter is
related to xstream->rows? So maybe define this type as size_t instead,
to be consistent with another occurence of WAL_ROWS_PER_YIELD. Say,
static size_t row_cnt = 0;
...
if (++row_cnt % WAL_ROWS_PER_YIELD == 0)
fiber_sleep(0);
I'm fine with uint64_t as well, just out of curiosity.
More information about the Tarantool-patches
mailing list