Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: "Георгий Кириченко" <georgy@tarantool.org>,
	tarantool-patches@freelists.org
Subject: Re: [tarantool-patches] [RFC v2] fiber: Increase default stack size
Date: Mon, 25 Feb 2019 18:25:30 +0300	[thread overview]
Message-ID: <20190225152530.GH7198@uranus> (raw)
In-Reply-To: <20190225145516.6fdmob3tdkft5sky@esperanza>

On Mon, Feb 25, 2019 at 05:55:16PM +0300, Vladimir Davydov wrote:
...
> > +
> > +static void
> > +stack_recycle(struct fiber *fiber)
> > +{
> > +	if (!fiber->stack || (fiber->flags & FIBER_CUSTOM_STACK))
> > +		return;
> > +
> > +	/*
> > +	 * If fiber was too eager for memory, just arm
> > +	 * a watermark back. Maybe on the next reuse
> > +	 * we will be able to relax RSS pressure.
> > +	 */
> > +	if (!stack_has_wmark(fiber)) {
> > +		fiber->flags &= ~FIBER_MADVISED_STACK;
> > +		stack_set_wmark(fiber);
> > +		return;
> > +	}
> 
> Hmm, I don't quite understand why you free the stack only if the fiber
> hasn't touched the watermark. See, there may be thousands of fibers out
> there which are chosen randomly to execute a CALL request that needs a
> lot of stack. If this CALL request happens to land on different fibers
> all the time, we will quickly wind up with a lot of memory being used
> for fiber stacks.
> 
> That being said, I think we should unconditionally free the stack with
> madvise() on fiber_recycle() if the watermark was overwritten. This
> would also simplify the patch as you won't need to introduce a new fiber
> flag then (FIBER_MADVISED_STACK).
> 
> Am I missing something?

Nope, you're not. I'm trying to minimize madvise() call since it is
a quite expencive call. And I don't like the idea of calling it
unconditionally (seriously, pte range invalidation is not cheap
at all, which involves tlb flushes and such). Letme think more...

> > +
> > +		/*
> > +		 * Set the flag iif we've successed,
> > +		 * otherwise will try on the next round.
> > +		 */
> > +		if (!madvise(fiber->stack, size, MADV_DONTNEED))
> 
> This is nitpicking, but in tarantool we use logical negation (!) only
> with bools. We compare integer values with 0 explicitly.

sure, will update.

  reply	other threads:[~2019-02-25 15:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22 20:16 Cyrill Gorcunov
2019-02-25 14:55 ` Vladimir Davydov
2019-02-25 15:25   ` Cyrill Gorcunov [this message]
2019-02-25 21:39   ` [RFC v3] " Cyrill Gorcunov
2019-02-26  8:58     ` Vladimir Davydov
2019-02-26  9:12       ` Cyrill Gorcunov
2019-02-26 10:26         ` Vladimir Davydov
2019-02-26 10:36           ` Vladimir Davydov
2019-02-26 11:17             ` Cyrill Gorcunov
2019-02-26 12:25               ` Vladimir Davydov
2019-02-26 11:16           ` Cyrill Gorcunov
2019-02-26 12:34             ` Vladimir Davydov
2019-02-26 12:54               ` Cyrill Gorcunov
2019-02-26 13:06                 ` Vladimir Davydov
2019-02-26 13:26               ` [tarantool-patches] " Konstantin Osipov
2019-02-26 14:02                 ` Cyrill Gorcunov
2019-02-26 10:32     ` Vladimir Davydov
2019-02-26 11:18       ` Cyrill Gorcunov

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=20190225152530.GH7198@uranus \
    --to=gorcunov@gmail.com \
    --cc=georgy@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [tarantool-patches] [RFC v2] fiber: Increase default stack size' \
    /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