Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Konstantin Osipov <kostja@tarantool.org>
Cc: tarantool-patches@freelists.org, vdavydov.dev@gmail.com
Subject: Re: [tarantool-patches] [rfc 4/4] core/fiber: Shrink stack when recycling
Date: Tue, 5 Mar 2019 11:41:10 +0300	[thread overview]
Message-ID: <20190305084110.GM13301@uranus.lan> (raw)
In-Reply-To: <20190305083048.GM21955@chai>

On Tue, Mar 05, 2019 at 11:30:48AM +0300, Konstantin Osipov wrote:
> * Cyrill Gorcunov <gorcunov@gmail.com> [19/03/03 23:25]:
> > +#define wmark_freeze(_pp) do { *((uintptr_t *)(_pp)) |= (uintptr_t)1; } while (0)
> > +#define wmark_frozen(_p) ((uintptr_t)(_p) & (uintptr_t)1)
> 
> Why not static inline? A comment would help. Usually the name for
> function returning true/false contains "is", e.g. wmark_is_frozen().

Well, surely we can use inlines here, I simply tried to make less code.
Seriously fiber.c looks too bloating. Maybe we should move all this
machinery into fiber-stack.cc?

...
> > +
> > +	if (wmark_frozen(fiber->stack_wmark))
> > +		return;
> > +
> > +	/*
> > +	 * On recycle we're trying to shrink stack
> > +	 * as much as we can until first mark overwrite
> > +	 * detected, then we simply freeze watermark and
> > +	 * assume the stack is balanced and won't change
> > +	 * much in future.
> > +	 */
> > +	if (!stack_has_wmark(fiber->stack_wmark))
> > +		wmark_freeze(&fiber->stack_wmark);
> 
> I don't see how "frozen" watermark concept is more powerful than
> already existing "overflow warned" flag. I think the idea is to
> have some sort of smart threshold after which we stop trying to
> shrink the stack.
> 
> Right now this threshold is not too smart (which is OK), but
> complicated (both overflow_warned and wmark_frozen() are
> considered), which doesn't make too much sense to me.

Look, the idea is too keep _two_ tests: one when stack is close
to overflow, we do this test every recycle and never move the
mark to other place; this page with overflow mark will be
always present.

In turn overflow mark is shrinked every recycle until first rewrite
detected. Then we simply zap the pointer and never test it again.

If you mean something else, lets talk f2f?

  reply	other threads:[~2019-03-05  8:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-02 12:55 [rfc 0/4] fiber/stack: Increase stack size and shrink rss usage Cyrill Gorcunov
2019-03-02 12:55 ` [rfc 1/4] core/fiber: Increase default stack size Cyrill Gorcunov
2019-03-02 12:55 ` [rfc 2/4] core/fiber: Mark stack as unneeded on creation Cyrill Gorcunov
2019-03-02 12:55 ` [rfc 3/4] core/fiber: Put static watermark into stack to track its usage Cyrill Gorcunov
2019-03-05  8:08   ` [tarantool-patches] " Konstantin Osipov
2019-03-05  8:17     ` Cyrill Gorcunov
2019-03-05  8:10   ` Konstantin Osipov
2019-03-05  8:14     ` Cyrill Gorcunov
2019-03-05 19:17     ` Cyrill Gorcunov
2019-03-05  8:20   ` Konstantin Osipov
2019-03-05  8:27     ` Cyrill Gorcunov
2019-03-02 12:55 ` [rfc 4/4] core/fiber: Shrink stack when recycling Cyrill Gorcunov
2019-03-05  8:30   ` [tarantool-patches] " Konstantin Osipov
2019-03-05  8:41     ` Cyrill Gorcunov [this message]
2019-03-05  9:32       ` [tarantool-patches] " Konstantin Osipov

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=20190305084110.GM13301@uranus.lan \
    --to=gorcunov@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [tarantool-patches] [rfc 4/4] core/fiber: Shrink stack when recycling' \
    /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