From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Oleg Babin <olegrok@tarantool.org>, tarantool-patches@dev.tarantool.org, yaroslav.dynnikov@tarantool.org Subject: Re: [Tarantool-patches] [PATCH vshard 10/11] sched: introduce vshard.storage.sched module Date: Wed, 24 Feb 2021 22:50:02 +0100 [thread overview] Message-ID: <214fcc16-f57c-71be-fe5a-473ad6be2c10@tarantool.org> (raw) In-Reply-To: <5e011bc2-426b-e59a-f165-fef74f998b18@tarantool.org> Thanks for the review! On 24.02.2021 11:28, Oleg Babin wrote: > Thanks for you patch. It's a brief review - I hope I'll look once again on this patch. > > Consider 2 comments below. > > >> diff --git a/vshard/storage/ref.lua b/vshard/storage/ref.lua >> index 7589cb9..2daad6b 100644 >> --- a/vshard/storage/ref.lua >> +++ b/vshard/storage/ref.lua >> @@ -341,6 +358,14 @@ local function ref_del(rid, sid) >> return session:del(rid) >> end >> +local function ref_next_deadline() >> + local session = M.session_heap:top() >> + if not session then >> + return fiber_clock() + TIMEOUT_INFINITY >> + end > > Does it make sence? inf + fiber_clock() = inf Indeed. I could simply return the infinite deadline. ==================== local fiber_clock = lfiber.clock local fiber_yield = lfiber.yield local DEADLINE_INFINITY = lconsts.DEADLINE_INFINITY -local TIMEOUT_INFINITY = lconsts.TIMEOUT_INFINITY local LUA_CHUNK_SIZE = lconsts.LUA_CHUNK_SIZE ==================== local function ref_next_deadline() local session = M.session_heap:top() - if not session then - return fiber_clock() + TIMEOUT_INFINITY - end - return session.deadline + return session and session.deadline or DEADLINE_INFINITY end ==================== >> diff --git a/vshard/storage/sched.lua b/vshard/storage/sched.lua >> new file mode 100644 >> index 0000000..0ac71f4 >> --- /dev/null >> +++ b/vshard/storage/sched.lua >> @@ -0,0 +1,231 @@ >> +local function sched_wait_anything(timeout) >> + return fiber_cond_wait(M.cond, timeout) >> +end >> + >> +-- >> +-- Return the remaining timeout in case there was a yield. This helps to save >> +-- current clock get in the caller code if there were no yields. >> +-- >> +local function sched_ref_start(timeout) >> + local deadline = fiber_clock() + timeout > > Let's do it after fast check to eliminate excess fiber_clock call. > > Also there are several similar places below. Please fix them as well. Good idea, fixed. However there are just 2 such places. ==================== @@ -79,13 +79,13 @@ end -- current clock get in the caller code if there were no yields. -- local function sched_ref_start(timeout) - local deadline = fiber_clock() + timeout - local ok, err + local deadline, ok, err -- Fast-path. Moves are extremely rare. No need to inc-dec the ref queue -- then nor try to start some loops. if M.move_count == 0 and M.move_queue == 0 then goto success end + deadline = fiber_clock() + timeout M.ref_queue = M.ref_queue + 1 @@ -132,8 +132,7 @@ end -- current clock get in the caller code if there were no yields. -- local function sched_move_start(timeout) - local deadline = fiber_clock() + timeout - local ok, err, ref_deadline + local ok, err, deadline, ref_deadline local lref = lregistry.storage_ref -- Fast-path. Refs are not extremely rare *when used*. But they are not -- expected to be used in a lot of installations. So most of the times the @@ -141,6 +140,7 @@ local function sched_move_start(timeout) if M.ref_count == 0 and M.ref_queue == 0 then goto success end + deadline = fiber_clock() + timeout M.move_queue = M.move_queue + 1 ==================== I also removed some debug code which I forgot first time: ==================== @@ -18,11 +18,6 @@ local small_timeout = 0.000001 -- rebalancer. -- -box.cfg{ - log = 'log.txt' -} --- io.write = function(...) require('log').info(...) end - -- ====================
next prev parent reply other threads:[~2021-02-24 21:50 UTC|newest] Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-23 0:15 [Tarantool-patches] [PATCH vshard 00/11] VShard Map-Reduce, part 2: Ref, Sched, Map Vladislav Shpilevoy via Tarantool-patches 2021-02-23 0:15 ` [Tarantool-patches] [PATCH vshard 01/11] error: introduce vshard.error.timeout() Vladislav Shpilevoy via Tarantool-patches 2021-02-24 10:27 ` Oleg Babin via Tarantool-patches 2021-02-24 21:46 ` Vladislav Shpilevoy via Tarantool-patches 2021-02-25 12:42 ` Oleg Babin via Tarantool-patches 2021-02-23 0:15 ` [Tarantool-patches] [PATCH vshard 10/11] sched: introduce vshard.storage.sched module Vladislav Shpilevoy via Tarantool-patches 2021-02-24 10:28 ` Oleg Babin via Tarantool-patches 2021-02-24 21:50 ` Vladislav Shpilevoy via Tarantool-patches [this message] 2021-03-04 21:02 ` Oleg Babin via Tarantool-patches 2021-03-05 22:06 ` Vladislav Shpilevoy via Tarantool-patches 2021-03-09 8:03 ` Oleg Babin via Tarantool-patches 2021-02-23 0:15 ` [Tarantool-patches] [PATCH vshard 11/11] router: introduce map_callrw() Vladislav Shpilevoy via Tarantool-patches 2021-02-24 10:28 ` Oleg Babin via Tarantool-patches 2021-02-24 22:04 ` Vladislav Shpilevoy via Tarantool-patches 2021-02-25 12:43 ` Oleg Babin via Tarantool-patches 2021-02-26 23:58 ` Vladislav Shpilevoy via Tarantool-patches 2021-03-01 10:58 ` Oleg Babin via Tarantool-patches 2021-02-23 0:15 ` [Tarantool-patches] [PATCH vshard 02/11] storage: add helper for local functions invocation Vladislav Shpilevoy via Tarantool-patches 2021-02-24 10:27 ` Oleg Babin via Tarantool-patches 2021-02-23 0:15 ` [Tarantool-patches] [PATCH vshard 03/11] storage: cache bucket count Vladislav Shpilevoy via Tarantool-patches 2021-02-24 10:27 ` Oleg Babin via Tarantool-patches 2021-02-24 21:47 ` Vladislav Shpilevoy via Tarantool-patches 2021-02-25 12:42 ` Oleg Babin via Tarantool-patches 2021-02-23 0:15 ` [Tarantool-patches] [PATCH vshard 04/11] registry: module for circular deps resolution Vladislav Shpilevoy via Tarantool-patches 2021-02-24 10:27 ` Oleg Babin via Tarantool-patches 2021-02-23 0:15 ` [Tarantool-patches] [PATCH vshard 05/11] util: introduce safe fiber_cond_wait() Vladislav Shpilevoy via Tarantool-patches 2021-02-24 10:27 ` Oleg Babin via Tarantool-patches 2021-02-24 21:48 ` Vladislav Shpilevoy via Tarantool-patches 2021-02-25 12:42 ` Oleg Babin via Tarantool-patches 2021-02-23 0:15 ` [Tarantool-patches] [PATCH vshard 06/11] util: introduce fiber_is_self_canceled() Vladislav Shpilevoy via Tarantool-patches 2021-02-24 10:27 ` Oleg Babin via Tarantool-patches 2021-02-23 0:15 ` [Tarantool-patches] [PATCH vshard 07/11] storage: introduce bucket_generation_wait() Vladislav Shpilevoy via Tarantool-patches 2021-02-24 10:27 ` Oleg Babin via Tarantool-patches 2021-02-23 0:15 ` [Tarantool-patches] [PATCH vshard 08/11] storage: introduce bucket_are_all_rw() Vladislav Shpilevoy via Tarantool-patches 2021-02-24 10:27 ` Oleg Babin via Tarantool-patches 2021-02-24 21:48 ` Vladislav Shpilevoy via Tarantool-patches 2021-02-23 0:15 ` [Tarantool-patches] [PATCH vshard 09/11] ref: introduce vshard.storage.ref module Vladislav Shpilevoy via Tarantool-patches 2021-02-24 10:28 ` Oleg Babin via Tarantool-patches 2021-02-24 21:49 ` Vladislav Shpilevoy via Tarantool-patches 2021-02-25 12:42 ` Oleg Babin via Tarantool-patches 2021-03-04 21:22 ` Oleg Babin via Tarantool-patches 2021-03-05 22:06 ` Vladislav Shpilevoy via Tarantool-patches 2021-03-09 8:03 ` Oleg Babin via Tarantool-patches 2021-03-21 18:49 ` Vladislav Shpilevoy via Tarantool-patches 2021-03-12 23:13 ` [Tarantool-patches] [PATCH vshard 00/11] VShard Map-Reduce, part 2: Ref, Sched, Map Vladislav Shpilevoy via Tarantool-patches 2021-03-15 7:05 ` Oleg Babin via Tarantool-patches 2021-03-28 18:17 ` Vladislav Shpilevoy 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=214fcc16-f57c-71be-fe5a-473ad6be2c10@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=olegrok@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --cc=yaroslav.dynnikov@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH vshard 10/11] sched: introduce vshard.storage.sched module' \ /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