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 DDCD46EC40; Fri, 13 Aug 2021 16:00:05 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DDCD46EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1628859606; bh=pARewCvJjmPJ5U/uv7/O/gWOynGzxup6CJP8Z8woaHo=; h=References:In-Reply-To:Date:To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=mfMIxWDBBzDuOQavVpGICCzihOKmE392tXkrqDZhOFANI1/fwQjxU5KfodJg+0Yy0 0TEox3ItUEqHSFOc2Ce5WV3zmxIRnUp13aK0+BxlpTnqjUt2i41+B29HPrZTMfokYE iTK3VDDpLl2bUskqPVV2M7aonXUgtMecd4+m+UCo= Received: from smtp16.mail.ru (smtp16.mail.ru [94.100.176.153]) (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 6A4B46EC40 for ; Fri, 13 Aug 2021 16:00:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6A4B46EC40 Received: by smtp16.mail.ru with esmtpa (envelope-from ) id 1mEWn5-0002hp-RV for tarantool-patches@dev.tarantool.org; Fri, 13 Aug 2021 16:00:04 +0300 Received: by mail-lf1-f44.google.com with SMTP id g30so19736470lfv.4 for ; Fri, 13 Aug 2021 06:00:03 -0700 (PDT) X-Gm-Message-State: AOAM530GVGzvUjB5BLra62C49jZafoT8GITWSr0VJdE4kgiLM3miSwSw VpnP6LKgnXGGX/IFh+pPSKZ72hkDNHy2Ks5TtQ== X-Google-Smtp-Source: ABdhPJzaDODiCKo3TX2ckvGcF6EvbvOMeyh7A0JJvrWDYBM7Jb04xa21LvW8npfg5wzXHELKv8D8QEcfZIktN9Hp0go= X-Received: by 2002:a05:6512:3044:: with SMTP id b4mr1561643lfb.35.1628859603458; Fri, 13 Aug 2021 06:00:03 -0700 (PDT) MIME-Version: 1.0 References: <923e00dac8a59e44dc2a87d44385812ea9d38db0.1628850359.git.vdavydov@tarantool.org> In-Reply-To: <923e00dac8a59e44dc2a87d44385812ea9d38db0.1628850359.git.vdavydov@tarantool.org> Date: Fri, 13 Aug 2021 15:59:43 +0300 X-Gmail-Original-Message-ID: Message-ID: To: Vladimir Davydov Cc: tml , Vladislav Shpilevoy , Yaroslav Dynnikov Content-Type: multipart/alternative; boundary="0000000000000da29405c9706e35" X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD9736CF3E71F18CE0C3E1D5927724F4AAA182A05F538085040D497040CB4E56C57B6732C55AD0A8290A9BFB225BBFD1482EBAA674B1BB0148E X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE711E64E073C139C7EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006372D22CC9620B7D5068638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D83A46C1C78EEEF29A8B02E46ECA2559DA117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18C26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE7532CA1512B819817B089FF177BE8049D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE3251EFD5447B32ED603F1AB874ED89028C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637F021E9262E629966EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B505CB1D0731E77493FA7FCEADF035605160 X-C1DE0DAB: 0D63561A33F958A567541AA05CCDF3D6A26256E400CE35B4AD23E435BE3609D6D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA750E14360347543F58410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3483E1FCD56FEA62E62FB68AE86C13E89E820FED693B1098598C841E6EDE08098B33A03E6A11DD1DB01D7E09C32AA3244C84923D96CAD00C2047BAF9549A1D79D9F2F5F14F68F1805B3EB3F6AD6EA9203E X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj0dLV0c3jbkxeOxn18gMPxA== X-Mailru-Sender: 4C235FE2E5D2D89058A75960CEDC992EC3C9188B8FC7091EA8BA2C797117CBEE9671DB1F4478FE7353E6F1E4007818E061AB7FC983AAE23E992E2169F9161B8DDAB93E5CC8760AFE9437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH] net.box: do not yield in future.wait_result(0) 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: Yaroslav Dynnikov via Tarantool-patches Reply-To: Yaroslav Dynnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" --0000000000000da29405c9706e35 Content-Type: text/plain; charset="UTF-8" Thanks for your patch. LGTM. Best regards Yaroslav Dynnikov On Fri, 13 Aug 2021 at 13:27, Vladimir Davydov wrote: > It didn't yield before commit 954194a1ca5c ("net.box: rewrite request > implementation in C"). It shouldn't yield now. > > Follow-up #6241 > --- > > https://github.com/tarantool/tarantool/tree/vdavydov/netbox-dont-yield-in-future-wait-result-if-timeout-is-0 > > src/box/lua/net_box.c | 2 ++ > test/box/net.box_fiber-async_gh-3107.result | 26 +++++++++++++++++++ > test/box/net.box_fiber-async_gh-3107.test.lua | 12 +++++++++ > 3 files changed, 40 insertions(+) > > diff --git a/src/box/lua/net_box.c b/src/box/lua/net_box.c > index 229dec590cf9..43a7d78a1122 100644 > --- a/src/box/lua/net_box.c > +++ b/src/box/lua/net_box.c > @@ -235,6 +235,8 @@ netbox_request_complete(struct netbox_request *request) > static inline bool > netbox_request_wait(struct netbox_request *request, double *timeout) > { > + if (*timeout == 0) > + return false; > double ts = ev_monotonic_now(loop()); > int rc = fiber_cond_wait_timeout(&request->cond, *timeout); > *timeout -= ev_monotonic_now(loop()) - ts; > diff --git a/test/box/net.box_fiber-async_gh-3107.result > b/test/box/net.box_fiber-async_gh-3107.result > index aaaca351a579..60f084ca3130 100644 > --- a/test/box/net.box_fiber-async_gh-3107.result > +++ b/test/box/net.box_fiber-async_gh-3107.result > @@ -104,6 +104,32 @@ err:find('Usage') ~= nil > --- > - true > ... > +-- > +-- Check that wait_result(0) doesn't yield. > +-- > +future = c:call('long_function', {1, 2, 3}, {is_async = true}) > +--- > +... > +csw1 = fiber.info()[fiber.id()].csw \ > +ret = future:wait_result(0) \ > +csw2 = fiber.info()[fiber.id()].csw > +--- > +... > +ret -- timeout > +--- > +- null > +... > +csw2 - csw1 -- 0 > +--- > +- 0 > +... > +finalize_long() > +--- > +... > +future:wait_result() > +--- > +- [1, 2, 3] > +... > box.schema.func.drop('long_function') > --- > ... > diff --git a/test/box/net.box_fiber-async_gh-3107.test.lua > b/test/box/net.box_fiber-async_gh-3107.test.lua > index d23f368cbce4..9632e9228bbb 100644 > --- a/test/box/net.box_fiber-async_gh-3107.test.lua > +++ b/test/box/net.box_fiber-async_gh-3107.test.lua > @@ -36,6 +36,18 @@ err:find('Usage') ~= nil > _, err = pcall(future.wait_result, future, '100') > err:find('Usage') ~= nil > > +-- > +-- Check that wait_result(0) doesn't yield. > +-- > +future = c:call('long_function', {1, 2, 3}, {is_async = true}) > +csw1 = fiber.info()[fiber.id()].csw \ > +ret = future:wait_result(0) \ > +csw2 = fiber.info()[fiber.id()].csw > +ret -- timeout > +csw2 - csw1 -- 0 > +finalize_long() > +future:wait_result() > + > box.schema.func.drop('long_function') > > c:close() > -- > 2.25.1 > > --0000000000000da29405c9706e35 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks for your patch. LGTM.

<= div>
Best regards
Yaroslav Dynnikov


On Fri, 13 Aug 2021 at 13:2= 7, Vladimir Davydov <vdavydov@tarantool.org> wrote:
It didn't yield before commit 954194a1= ca5c ("net.box: rewrite request
implementation in C"). It shouldn't yield now.

Follow-up #6241
---
https://github.com/tarantool/tarantool/tree/vdavydov/netbox-dont-yi= eld-in-future-wait-result-if-timeout-is-0

=C2=A0src/box/lua/net_box.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 2 ++
=C2=A0test/box/net.box_fiber-async_gh-3107.result=C2=A0 =C2=A0| 26 ++++++++= +++++++++++
=C2=A0test/box/net.box_fiber-async_gh-3107.test.lua | 12 +++++++++
=C2=A03 files changed, 40 insertions(+)

diff --git a/src/box/lua/net_box.c b/src/box/lua/net_box.c
index 229dec590cf9..43a7d78a1122 100644
--- a/src/box/lua/net_box.c
+++ b/src/box/lua/net_box.c
@@ -235,6 +235,8 @@ netbox_request_complete(struct netbox_request *request)=
=C2=A0static inline bool
=C2=A0netbox_request_wait(struct netbox_request *request, double *timeout)<= br> =C2=A0{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (*timeout =3D=3D 0)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return false;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 double ts =3D ev_monotonic_now(loop());
=C2=A0 =C2=A0 =C2=A0 =C2=A0 int rc =3D fiber_cond_wait_timeout(&request= ->cond, *timeout);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 *timeout -=3D ev_monotonic_now(loop()) - ts; diff --git a/test/box/net.box_fiber-async_gh-3107.result b/test/box/net.box= _fiber-async_gh-3107.result
index aaaca351a579..60f084ca3130 100644
--- a/test/box/net.box_fiber-async_gh-3107.result
+++ b/test/box/net.box_fiber-async_gh-3107.result
@@ -104,6 +104,32 @@ err:find('Usage') ~=3D nil
=C2=A0---
=C2=A0- true
=C2=A0...
+--
+-- Check that wait_result(0) doesn't yield.
+--
+future =3D c:call('long_function', {1, 2, 3}, {is_async =3D true})=
+---
+...
+csw1 =3D fiber.info()[fiber.id()].csw \
+ret =3D future:wait_result(0)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\
+csw2 =3D fiber.info()[fiber.id()].csw
+---
+...
+ret -- timeout
+---
+- null
+...
+csw2 - csw1 -- 0
+---
+- 0
+...
+finalize_long()
+---
+...
+future:wait_result()
+---
+- [1, 2, 3]
+...
=C2=A0box.schema.func.drop('long_function')
=C2=A0---
=C2=A0...
diff --git a/test/box/net.box_fiber-async_gh-3107.test.lua b/test/box/net.b= ox_fiber-async_gh-3107.test.lua
index d23f368cbce4..9632e9228bbb 100644
--- a/test/box/net.box_fiber-async_gh-3107.test.lua
+++ b/test/box/net.box_fiber-async_gh-3107.test.lua
@@ -36,6 +36,18 @@ err:find('Usage') ~=3D nil
=C2=A0_, err =3D pcall(future.wait_result, future, '100')
=C2=A0err:find('Usage') ~=3D nil

+--
+-- Check that wait_result(0) doesn't yield.
+--
+future =3D c:call('long_function', {1, 2, 3}, {is_async =3D true})=
+csw1 =3D fiber.info()[fiber.id()].csw \
+ret =3D future:wait_result(0)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\
+csw2 =3D fiber.info()[fiber.id()].csw
+ret -- timeout
+csw2 - csw1 -- 0
+finalize_long()
+future:wait_result()
+
=C2=A0box.schema.func.drop('long_function')

=C2=A0c:close()
--
2.25.1

--0000000000000da29405c9706e35--