* [Tarantool-patches] [PATCH] net.box: do not yield in future.wait_result(0) @ 2021-08-13 10:27 Vladimir Davydov via Tarantool-patches 2021-08-13 12:14 ` [Tarantool-patches] [PATCH v2] " Vladimir Davydov via Tarantool-patches 2021-08-13 12:59 ` [Tarantool-patches] [PATCH] " Yaroslav Dynnikov via Tarantool-patches 0 siblings, 2 replies; 6+ messages in thread From: Vladimir Davydov via Tarantool-patches @ 2021-08-13 10:27 UTC (permalink / raw) To: tarantool-patches; +Cc: v.shpilevoy, yaroslav.dynnikov 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Tarantool-patches] [PATCH v2] net.box: do not yield in future.wait_result(0) 2021-08-13 10:27 [Tarantool-patches] [PATCH] net.box: do not yield in future.wait_result(0) Vladimir Davydov via Tarantool-patches @ 2021-08-13 12:14 ` Vladimir Davydov via Tarantool-patches 2021-08-13 14:15 ` Yaroslav Dynnikov via Tarantool-patches 2021-08-13 12:59 ` [Tarantool-patches] [PATCH] " Yaroslav Dynnikov via Tarantool-patches 1 sibling, 1 reply; 6+ messages in thread From: Vladimir Davydov via Tarantool-patches @ 2021-08-13 12:14 UTC (permalink / raw) To: tarantool-patches; +Cc: v.shpilevoy, yaroslav.dynnikov 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Tarantool-patches] [PATCH v2] net.box: do not yield in future.wait_result(0) 2021-08-13 12:14 ` [Tarantool-patches] [PATCH v2] " Vladimir Davydov via Tarantool-patches @ 2021-08-13 14:15 ` Yaroslav Dynnikov via Tarantool-patches 2021-08-16 10:38 ` Vitaliia Ioffe via Tarantool-patches 0 siblings, 1 reply; 6+ messages in thread From: Yaroslav Dynnikov via Tarantool-patches @ 2021-08-13 14:15 UTC (permalink / raw) To: Vladimir Davydov; +Cc: tml, Vladislav Shpilevoy, Yaroslav Dynnikov [-- Attachment #1: Type: text/plain, Size: 3874 bytes --] 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-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 > > [-- Attachment #2: Type: text/html, Size: 5665 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Tarantool-patches] [PATCH v2] net.box: do not yield in future.wait_result(0) 2021-08-13 14:15 ` Yaroslav Dynnikov via Tarantool-patches @ 2021-08-16 10:38 ` Vitaliia Ioffe via Tarantool-patches 2021-08-16 10:47 ` Vladimir Davydov via Tarantool-patches 0 siblings, 1 reply; 6+ messages in thread From: Vitaliia Ioffe via Tarantool-patches @ 2021-08-16 10:38 UTC (permalink / raw) To: Vladimir Davydov; +Cc: tml, Vladislav Shpilevoy [-- Attachment #1: Type: text/plain, Size: 4268 bytes --] Hi team, QA LGTM -- Vitaliia Ioffe >Пятница, 13 августа 2021, 17:15 +03:00 от Yaroslav Dynnikov via Tarantool-patches <tarantool-patches@dev.tarantool.org>: > >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-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 >> [-- Attachment #2: Type: text/html, Size: 6627 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Tarantool-patches] [PATCH v2] net.box: do not yield in future.wait_result(0) 2021-08-16 10:38 ` Vitaliia Ioffe via Tarantool-patches @ 2021-08-16 10:47 ` Vladimir Davydov via Tarantool-patches 0 siblings, 0 replies; 6+ messages in thread From: Vladimir Davydov via Tarantool-patches @ 2021-08-16 10:47 UTC (permalink / raw) To: tarantool-patches Pushed to master. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Tarantool-patches] [PATCH] net.box: do not yield in future.wait_result(0) 2021-08-13 10:27 [Tarantool-patches] [PATCH] net.box: do not yield in future.wait_result(0) Vladimir Davydov via Tarantool-patches 2021-08-13 12:14 ` [Tarantool-patches] [PATCH v2] " Vladimir Davydov via Tarantool-patches @ 2021-08-13 12:59 ` Yaroslav Dynnikov via Tarantool-patches 1 sibling, 0 replies; 6+ messages in thread From: Yaroslav Dynnikov via Tarantool-patches @ 2021-08-13 12:59 UTC (permalink / raw) To: Vladimir Davydov; +Cc: tml, Vladislav Shpilevoy, Yaroslav Dynnikov [-- Attachment #1: Type: text/plain, Size: 2829 bytes --] Thanks for your patch. LGTM. Best regards Yaroslav Dynnikov On Fri, 13 Aug 2021 at 13:27, 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-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 > > [-- Attachment #2: Type: text/html, Size: 4409 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-08-16 10:47 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-08-13 10:27 [Tarantool-patches] [PATCH] net.box: do not yield in future.wait_result(0) Vladimir Davydov via Tarantool-patches 2021-08-13 12:14 ` [Tarantool-patches] [PATCH v2] " Vladimir Davydov via Tarantool-patches 2021-08-13 14:15 ` Yaroslav Dynnikov via Tarantool-patches 2021-08-16 10:38 ` Vitaliia Ioffe via Tarantool-patches 2021-08-16 10:47 ` Vladimir Davydov via Tarantool-patches 2021-08-13 12:59 ` [Tarantool-patches] [PATCH] " Yaroslav Dynnikov via Tarantool-patches
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox