From: Konstantin Osipov <kostja@tarantool.org> To: tarantool-patches@freelists.org Subject: [tarantool-patches] Re: [PATCH 1/1] swim: keep encoded round message cached Date: Thu, 11 Apr 2019 16:51:50 +0300 [thread overview] Message-ID: <20190411135150.GA5480@chai> (raw) In-Reply-To: <573c97faff11b387566fd449c1d1dcbe3e644351.1554893660.git.v.shpilevoy@tarantool.org> * Vladislav Shpilevoy <v.shpilevoy@tarantool.org> [19/04/10 17:15]: > During a SWIM round a message is being handed out consisting of > at most 4 sections. Parts of the message change rarely along with > a member attribute update, or with removal of a member. So it is > possible to cache the message and send it during several round > steps in a row. Or even do not rebuild it the whole round. > > Part of #3234 > --- > Branch: https://github.com/tarantool/tarantool/tree/gerold103/gh-3234-swim-cached-msg > Issue: https://github.com/tarantool/tarantool/issues/3234 > > src/lib/swim/swim.c | 24 ++++++++++++++++++++---- > src/lib/swim/swim_io.h | 7 +++++++ > 2 files changed, 27 insertions(+), 4 deletions(-) > > diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c > index c64b8df3a..8453295a5 100644 > --- a/src/lib/swim/swim.c > +++ b/src/lib/swim/swim.c > @@ -417,6 +417,13 @@ struct swim { > struct rlist dissemination_queue; > }; > > +/** Reset cached round message on any change of any member. */ > +static inline void > +cached_round_msg_invalidate(struct swim *swim) > +{ > + swim_packet_create(&swim->round_step_task.packet); > +} Are you going to add anything to this method? If not, please get rid of it and inline swim_packet_create() to all relevant places, with an appropriate comment. > swim_on_member_update(struct swim *swim, struct swim_member *member) > { > member->unacknowledged_pings = 0; > + cached_round_msg_invalidate(swim); > swim_register_event(swim, member); Please move the call to cached_round_msg_invalidate() to swim_register_event(). Actually the three members - in_dissemination_queue, status_ttl and cached message - have interdependent life cycle. There are two major events to account for: - whenever you reset status_ttl you need to invalidate the cache and ensure the member is registered in the dissemination queue. - whenever status_ttl drops to zero the member is deleted from the dissemination queue and the cached message can be deleted as well. You have two relevant places for these two events: swim_register_event and swim_decrease_event_ttl(). It should be sufficient to add cache invalidation to them, plus initialize the cache in the constructor and destroy in the destructor. -- Konstantin Osipov, Moscow, Russia, +7 903 626 22 32 http://tarantool.io - www.twitter.com/kostja_osipov
next prev parent reply other threads:[~2019-04-11 13:51 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-04-10 10:55 [tarantool-patches] " Vladislav Shpilevoy 2019-04-10 11:00 ` [tarantool-patches] " Vladislav Shpilevoy 2019-04-11 13:51 ` Konstantin Osipov [this message] 2019-04-11 16:09 ` Vladislav Shpilevoy 2019-04-11 16:24 ` Konstantin Osipov 2019-04-11 17:22 ` Vladislav Shpilevoy
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=20190411135150.GA5480@chai \ --to=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='[tarantool-patches] Re: [PATCH 1/1] swim: keep encoded round message cached' \ /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