From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id B39496EC6F; Fri, 12 Feb 2021 15:08:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B39496EC6F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1613131735; bh=fSMpOrJF799ErK5mr8PSY1E86Vm2qlEnDYXllURqJ2E=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=AiqAM1dAzV1rq3WkKbUS54GMS80IpUU0qUFxGsTbGOZ2+i3UM3d6MS+jkUnsw9S5U llWY09Fh6WcZTvx8NfA+nIqwQ6T16D9Yr9M2mUhs51HFuofBZXjQwbzHJE99SEhcQp XGuGmD8ix4iKonFC1JGVHKwVCR8VNhkQZNqqoebE= Received: from smtp54.i.mail.ru (smtp54.i.mail.ru [217.69.128.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 5F38E6EC6F for ; Fri, 12 Feb 2021 15:08:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5F38E6EC6F Received: by smtp54.i.mail.ru with esmtpa (envelope-from ) id 1lAXFj-0004kD-VG; Fri, 12 Feb 2021 15:08:52 +0300 To: Cyrill Gorcunov Cc: v.shpilevoy@tarantool.org, tarantool-patches@dev.tarantool.org References: <20210212112541.27561-1-sergepetrenko@tarantool.org> Message-ID: <538dd07a-ca66-9513-4f5d-1abf2a05ad7a@tarantool.org> Date: Fri, 12 Feb 2021 15:08:51 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD981647AC6901E234B663C574FBA2C95D46270E7B1163DBA8E182A05F538085040F78DACD50FAA3E0996BA3CD016C57596DF6F99D79D8AF2FE2AFA385685B3380F X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE76C33606E6E3377E0EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637FB9B6852776FECD88638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FC16D72997506E19CE54D588404D05C53914F4BAC08A30B117389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0D9442B0B5983000E8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6E5E764EB5D94DBD4CC7F00164DA146DA6F5DAA56C3B73B23C77107234E2CFBA567F23339F89546C55F5C1EE8F4F765FC02324478173250CF75ECD9A6C639B01BBD4B6F7A4D31EC0BC0CAF46E325F83A522CA9DD8327EE4930A3850AC1BE2E735CCFFBAE954C2DE44C4224003CC836476C0CAF46E325F83A50BF2EBBBDD9D6B0F05F538519369F3743B503F486389A921A5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A5496B745D59115AA254B2378476EC9CF6ED6D216839D0D394D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34EB7BD66E9101C1009CD48A73432B012B33CDD3C36A42751CE674C3118D8B1D8F0B396F586FAEFE551D7E09C32AA3244C41377596777BFB26168ACB53C253B40030363D8B7DA7DD44FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojtEL/kbq1PXEDYD27SmAGTQ== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A4460B1138D207205DE9A393FC718DD807268AB51F4FA04311F3424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH] relay: yield explicitly every N sent rows X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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