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 C235F6EC40; Fri, 13 Aug 2021 17:15:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C235F6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1628864125; bh=xfOSdK2iV4E3P4xzvppn+pBsarzfQNCRkzAR21L7J8U=; 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=beFAC2ojTkpammhWcYq3stfzTTSccSkqSRMzS/6VVLWbQ7g1RUL4ldD3iMFky/4eI aOLepPBUzIwARK0MLVgqXmRjVe323rS5UN2eaTHXB+Exg1htYH+8ZGyW+gRuv1SghG QpyLEQFo/2MECJDxMvmFj5nGqXKG2xu05tPceYtg= Received: from smtp37.i.mail.ru (smtp37.i.mail.ru [94.100.177.97]) (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 3672F6EC40 for ; Fri, 13 Aug 2021 17:15:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3672F6EC40 Received: by smtp37.i.mail.ru with esmtpa (envelope-from ) id 1mEXxz-0006t4-JC for tarantool-patches@dev.tarantool.org; Fri, 13 Aug 2021 17:15:23 +0300 Received: by mail-lj1-f170.google.com with SMTP id m17so12066144ljp.7 for ; Fri, 13 Aug 2021 07:15:23 -0700 (PDT) X-Gm-Message-State: AOAM530+cZEyLCtwkJ7kIOCUZQG0Qc7PvbX3aM0W3Pr8SmDL54oDS7gE WSoCx34i2mZxAvAREgcWSIKEXj2Fr5rp+x8rww== X-Google-Smtp-Source: ABdhPJypesKobUqOXeDRnBgikSc/kS14Wb/Iw+iB/VNwEEygsLRy1O0lo8SVm1Af/2YTJrcoOUYgAruaFE6havAIFFM= X-Received: by 2002:a05:651c:1303:: with SMTP id u3mr1984702lja.231.1628864123214; Fri, 13 Aug 2021 07:15:23 -0700 (PDT) MIME-Version: 1.0 References: <923e00dac8a59e44dc2a87d44385812ea9d38db0.1628850359.git.vdavydov@tarantool.org> <7b986fe9f451e1211b97d564ad6ed2ced048997f.1628856798.git.vdavydov@tarantool.org> In-Reply-To: <7b986fe9f451e1211b97d564ad6ed2ced048997f.1628856798.git.vdavydov@tarantool.org> Date: Fri, 13 Aug 2021 17:15:03 +0300 X-Gmail-Original-Message-ID: Message-ID: To: Vladimir Davydov Cc: tml , Vladislav Shpilevoy , Yaroslav Dynnikov Content-Type: multipart/alternative; boundary="000000000000739f2705c9717b3c" X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD906AB4890CDABF0C5CB76CEE71D3E4007182A05F538085040403EEF8BC5B237E14D70C73423C6CFF8D90BEDC49D152FD5DD60F18365509971 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE76EFCC492048C0D13EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006375F0BD5CF353A411D8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8610FBCFCB461A9736BF124E8BB0BEC32117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18C26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE7B96B19DC409332103F1AB874ED890284AD6D5ED66289B52698AB9A7B718F8C46E0066C2D8992A16725E5C173C3A84C3C729CE01ACF73A21BA3038C0950A5D36B5C8C57E37DE458B0BC6067A898B09E46D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE754A400A07F115C59731C566533BA786AA5CC5B56E945C8DA X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B50548E762AB7E4537D3C60B1A8C4446ED91 X-C1DE0DAB: 0D63561A33F958A5E5E83D7485B4C8C1F97805E0B205CF1890480F260C92FC99D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA750E14360347543F58410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34D95739AEDB3821B4B8B7D58E2F81A5FC3667AA3615AA43852866AC1B79DAF5B1D287AB45820F5C101D7E09C32AA3244C12E7D4BF7E58B34E60EBA2B4FDCCEF3695A9E0DC41E9A4CF3EB3F6AD6EA9203E X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj0dLV0c3jbkwpN5lU5Y2lTw== X-Mailru-Sender: 4C235FE2E5D2D890480DECB9C5345EBD3A5F795E38BB8DD3010B2D317666496A2A4FD9711CBF16A47B6BBE17E403543AD070B20000CAF116B128302DCECB6B19FE2C68CC745D971B112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2] 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" --000000000000739f2705c9717b3c Content-Type: text/plain; charset="UTF-8" That's even better, still LGTM. Best regards Yaroslav Dynnikov On Fri, 13 Aug 2021 at 15:14, 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 > > Changes in v2: > - Improved test. > > src/box/lua/net_box.c | 2 + > test/box/net.box_fiber-async_gh-3107.result | 48 +++++++++++++++++++ > test/box/net.box_fiber-async_gh-3107.test.lua | 20 ++++++++ > 3 files changed, 70 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..ec2fd4f6441a 100644 > --- a/test/box/net.box_fiber-async_gh-3107.result > +++ b/test/box/net.box_fiber-async_gh-3107.result > @@ -104,6 +104,54 @@ err:find('Usage') ~= nil > --- > - true > ... > +-- > +-- Check that there's no unexpected yields. > +-- > +function assert_no_csw(func, ...) \ > + local csw1 = fiber.info()[fiber.id()].csw \ > + local ret = {func(...)} \ > + local csw2 = fiber.info()[fiber.id()].csw \ > + assert(csw2 - csw1 == 0) \ > + return unpack(ret) \ > +end > +--- > +... > +future = c:call('long_function', {1, 2, 3}, {is_async = true}) > +--- > +... > +assert_no_csw(future.is_ready, future) > +--- > +- false > +... > +assert_no_csw(future.result, future) > +--- > +- null > +- Response is not ready > +... > +assert_no_csw(future.wait_result, future, 0) > +--- > +- null > +- Timeout exceeded > +... > +finalize_long() > +--- > +... > +future:wait_result() > +--- > +- [1, 2, 3] > +... > +assert_no_csw(future.is_ready, future) > +--- > +- true > +... > +assert_no_csw(future.result, future) > +--- > +- [1, 2, 3] > +... > +assert_no_csw(future.wait_result, future) > +--- > +- [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..71ba50b62ccb 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,26 @@ err:find('Usage') ~= nil > _, err = pcall(future.wait_result, future, '100') > err:find('Usage') ~= nil > > +-- > +-- Check that there's no unexpected yields. > +-- > +function assert_no_csw(func, ...) \ > + local csw1 = fiber.info()[fiber.id()].csw \ > + local ret = {func(...)} \ > + local csw2 = fiber.info()[fiber.id()].csw \ > + assert(csw2 - csw1 == 0) \ > + return unpack(ret) \ > +end > +future = c:call('long_function', {1, 2, 3}, {is_async = true}) > +assert_no_csw(future.is_ready, future) > +assert_no_csw(future.result, future) > +assert_no_csw(future.wait_result, future, 0) > +finalize_long() > +future:wait_result() > +assert_no_csw(future.is_ready, future) > +assert_no_csw(future.result, future) > +assert_no_csw(future.wait_result, future) > + > box.schema.func.drop('long_function') > > c:close() > -- > 2.25.1 > > --000000000000739f2705c9717b3c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
That's even better, still LGTM.

Best regards
Yaroslav Dynnikov


On Fri, 13 Aug 2021 at 15:14, Vladimir Davydov <vdavydov@tarantool.org> 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-yi= eld-in-future-wait-result-if-timeout-is-0

Changes in v2:
=C2=A0- Improved test.

=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| 48 ++++++++= +++++++++++
=C2=A0test/box/net.box_fiber-async_gh-3107.test.lua | 20 ++++++++
=C2=A03 files changed, 70 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..ec2fd4f6441a 100644
--- a/test/box/net.box_fiber-async_gh-3107.result
+++ b/test/box/net.box_fiber-async_gh-3107.result
@@ -104,6 +104,54 @@ err:find('Usage') ~=3D nil
=C2=A0---
=C2=A0- true
=C2=A0...
+--
+-- Check that there's no unexpected yields.
+--
+function assert_no_csw(func, ...)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0\
+=C2=A0 =C2=A0 local csw1 =3D fiber.info()[fiber.id()].csw=C2=A0 =C2=A0\
+=C2=A0 =C2=A0 local ret =3D {func(...)}=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 local csw2 =3D fiber.info()[fiber.id()].csw=C2=A0 =C2=A0\
+=C2=A0 =C2=A0 assert(csw2 - csw1 =3D=3D 0)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \
+=C2=A0 =C2=A0 return unpack(ret)=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 \
+end
+---
+...
+future =3D c:call('long_function', {1, 2, 3}, {is_async =3D true})=
+---
+...
+assert_no_csw(future.is_ready, future)
+---
+- false
+...
+assert_no_csw(future.result, future)
+---
+- null
+- Response is not ready
+...
+assert_no_csw(future.wait_result, future, 0)
+---
+- null
+- Timeout exceeded
+...
+finalize_long()
+---
+...
+future:wait_result()
+---
+- [1, 2, 3]
+...
+assert_no_csw(future.is_ready, future)
+---
+- true
+...
+assert_no_csw(future.result, future)
+---
+- [1, 2, 3]
+...
+assert_no_csw(future.wait_result, future)
+---
+- [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..71ba50b62ccb 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,26 @@ err:find('Usage') ~=3D nil
=C2=A0_, err =3D pcall(future.wait_result, future, '100')
=C2=A0err:find('Usage') ~=3D nil

+--
+-- Check that there's no unexpected yields.
+--
+function assert_no_csw(func, ...)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0\
+=C2=A0 =C2=A0 local csw1 =3D fiber.info()[fiber.id()].csw=C2=A0 =C2=A0\
+=C2=A0 =C2=A0 local ret =3D {func(...)}=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 local csw2 =3D fiber.info()[fiber.id()].csw=C2=A0 =C2=A0\
+=C2=A0 =C2=A0 assert(csw2 - csw1 =3D=3D 0)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \
+=C2=A0 =C2=A0 return unpack(ret)=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 \
+end
+future =3D c:call('long_function', {1, 2, 3}, {is_async =3D true})=
+assert_no_csw(future.is_ready, future)
+assert_no_csw(future.result, future)
+assert_no_csw(future.wait_result, future, 0)
+finalize_long()
+future:wait_result()
+assert_no_csw(future.is_ready, future)
+assert_no_csw(future.result, future)
+assert_no_csw(future.wait_result, future)
+
=C2=A0box.schema.func.drop('long_function')

=C2=A0c:close()
--
2.25.1

--000000000000739f2705c9717b3c--