From: Serge Petrenko via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Cyrill Gorcunov <gorcunov@gmail.com> Cc: v.shpilevoy@tarantool.org, tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH] relay: yield explicitly every N sent rows Date: Fri, 12 Feb 2021 15:08:51 +0300 [thread overview] Message-ID: <538dd07a-ca66-9513-4f5d-1abf2a05ad7a@tarantool.org> (raw) In-Reply-To: <YCZojN87ply5GGfQ@grain> 12.02.2021 14:37, Cyrill Gorcunov пишет: > 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, Thanks for the review! Yes, it serves the same purpose. No problem, let it be size_t, updated. > 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. Looks fine. My bad, I didn't pay enough attention when writing the patch. ========================================================================= diff --git a/src/box/relay.cc b/src/box/relay.cc index afc57dfbc..1d8edf116 100644 --- a/src/box/relay.cc +++ b/src/box/relay.cc @@ -836,7 +836,7 @@ relay_send(struct relay *relay, struct xrow_header *packet) { ERROR_INJECT_YIELD(ERRINJ_RELAY_SEND_DELAY); - static uint64_t row_cnt = 0; + static size_t row_cnt = 0; packet->sync = relay->sync; relay->last_row_time = ev_monotonic_now(loop()); coio_write_xrow(&relay->io, packet); @@ -846,10 +846,9 @@ 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. */ - row_cnt++; - if (row_cnt % WAL_ROWS_PER_YIELD == 0) { + if (++row_cnt % WAL_ROWS_PER_YIELD == 0) fiber_sleep(0); - } + struct errinj *inj = errinj(ERRINJ_RELAY_TIMEOUT, ERRINJ_DOUBLE); if (inj != NULL && inj->dparam > 0) fiber_sleep(inj->dparam); -- Serge Petrenko
next prev parent reply other threads:[~2021-02-12 12:08 UTC|newest] Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-12 11:25 Serge Petrenko via Tarantool-patches 2021-02-12 11:37 ` Cyrill Gorcunov via Tarantool-patches 2021-02-12 11:46 ` Cyrill Gorcunov via Tarantool-patches 2021-02-12 12:08 ` Serge Petrenko via Tarantool-patches [this message] 2021-02-12 17:00 ` Cyrill Gorcunov via Tarantool-patches 2021-02-12 21:48 ` Vladislav Shpilevoy via Tarantool-patches 2021-02-12 22:25 ` Cyrill Gorcunov via Tarantool-patches 2021-02-15 8:45 ` Serge Petrenko via Tarantool-patches 2021-02-15 8:40 ` Serge Petrenko via Tarantool-patches 2021-02-17 21:11 ` Vladislav Shpilevoy via Tarantool-patches 2021-02-18 20:24 ` Serge Petrenko via Tarantool-patches 2021-02-23 22:30 ` Vladislav Shpilevoy via Tarantool-patches 2021-02-24 9:48 ` Serge Petrenko via Tarantool-patches 2021-02-24 10:15 ` Cyrill Gorcunov via Tarantool-patches 2021-02-24 10:35 ` Serge Petrenko via Tarantool-patches 2021-02-24 12:07 ` Cyrill Gorcunov via Tarantool-patches 2021-02-24 12:14 ` Serge Petrenko via Tarantool-patches 2021-02-24 22:20 ` Vladislav Shpilevoy via Tarantool-patches 2021-02-26 8:41 ` Kirill Yukhin via Tarantool-patches 2021-02-26 20:24 ` Vladislav Shpilevoy via Tarantool-patches 2021-03-01 11:25 ` Serge Petrenko via Tarantool-patches 2021-03-01 21:24 ` Vladislav Shpilevoy via Tarantool-patches 2021-03-02 9:52 ` Kirill Yukhin via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=538dd07a-ca66-9513-4f5d-1abf2a05ad7a@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=gorcunov@gmail.com \ --cc=sergepetrenko@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH] relay: yield explicitly every N sent rows' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox