Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: tml <tarantool-patches@freelists.org>,
	Konstantin Osipov <kostja@tarantool.org>
Subject: Re: [PATCH 2/2] lib/core/fiber: Allow to extend default stack size
Date: Wed, 27 Mar 2019 13:15:52 +0300	[thread overview]
Message-ID: <20190327101552.d3b6xvezm3rigszm@esperanza> (raw)
In-Reply-To: <20190327094618.GH20626@uranus.lan>

On Wed, Mar 27, 2019 at 12:46:18PM +0300, Cyrill Gorcunov wrote:
> On Wed, Mar 27, 2019 at 12:35:06PM +0300, Vladimir Davydov wrote:
> > > diff --git a/src/lib/core/fiber.c b/src/lib/core/fiber.c
> > > index 922a0bfe8..d3cb18a15 100644
> > > --- a/src/lib/core/fiber.c
> > > +++ b/src/lib/core/fiber.c
> > > @@ -107,18 +107,25 @@ pthread_t main_thread_id;
> > >  static size_t page_size;
> > >  static bool stack_growsdown;
> > >  
> > > +/** Indices in fiber stack sizes (FSS) */
> > >  enum {
> > > +	FSS_IDX_MINIMAL,
> > > +	FSS_IDX_WATERMARK,
> > > +	FSS_IDX_DEFAULT,
> > > +};
> > > +
> > > +/** Fiber stack sizes */
> > > +static size_t fiber_stack_size[] = {
> > >  	/* The minimum allowable fiber stack size in bytes */
> > > -	FIBER_STACK_SIZE_MINIMAL = 16384,
> > > +	[FSS_IDX_MINIMAL]	= 16384,
> > > +	/* Stack size watermark in bytes */
> > > +	[FSS_IDX_WATERMARK]	= 65536,
> > >  	/* Default fiber stack size in bytes */
> > > -	FIBER_STACK_SIZE_DEFAULT = 524288,
> > > -	/* Stack size watermark in bytes. */
> > > -	FIBER_STACK_SIZE_WATERMARK = 65536,
> > > +	[FSS_IDX_DEFAULT]	= 524288,
> > >  };
> > 
> > Please avoid unrelated changes. If you want to rename or refactor
> > something, do it in a separate patch to ease review.
> > 
> > Anyway, I don't see much point in this change - in Tarantool code it's
> > common to use a enum for storing constants.
> 
> These are not constants anymore since we're to ajust the values.

Ah, I see. Anyway, I'd leave the constants alone and instead introduce a
separate static variable to store the current stack size in, because
mixing constants (min_size, watermark) and variables (current_default)
in one array doesn't look good to me.

> 
> > > +/**
> > > + * Initialize early parameters of the stack
> > > + * and setup default variables.
> > > + */
> > > +static void
> > > +fiber_stack_init(void)
> > > +{
> > > +	static const char default_size_name[] = "FIBER_STACK_SIZE_DEFAULT";
> > 
> > There's a risk it may conflict with another environment variable.
> > At the very least, we should prefix it with TARANTOOL_.
> > 
> > However, I don't think that using an environmental variable is a proper
> > way to go. After all, Tarantool is an application server so we typically
> > set system variables right from Lua code.
> > 
> > Can we introduce a function in the fiber module for this? The tricky
> > part is that it should change the stack size of the calling fiber,
> > I guess.
> 
> Yes, stacks are allocated earlier, and we simply can't adjust already
> allocated stack thus we might need to distinguish stack sizes between
> cord_main and new fibers. This gonna be hard and I would like to escape
> such complexity. Seriously, we should use a hard rule: every stack in
> the engine has the same size allocated.
> 
> Lets think -- is there a chance we will have to provide more configurable
> settings for early init stage in future? If yes then we should invent
> early init stage for lua (or say some json fine in /etc). If no and
> there is no chance we might need something else in future, better to
> stick with simplier solution as environment variables.

Makes sense. But as this is a change in the API, we should consult
Kostja (Cc-ed).

  reply	other threads:[~2019-03-27 10:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19 19:38 [RFC 0/2] lib/core/fiber: Allow to extend stack size via env variable Cyrill Gorcunov
2019-03-19 19:38 ` [PATCH 1/2] lib/core/fiber: Rename stack_direction to stack_growsdown Cyrill Gorcunov
2019-03-27  9:35   ` Vladimir Davydov
2019-03-27  9:48     ` Cyrill Gorcunov
2019-03-27 10:20       ` Vladimir Davydov
2019-03-27 10:30         ` Cyrill Gorcunov
2019-03-19 19:38 ` [PATCH 2/2] lib/core/fiber: Allow to extend default stack size Cyrill Gorcunov
2019-03-27  9:35   ` Vladimir Davydov
2019-03-27  9:46     ` Cyrill Gorcunov
2019-03-27 10:15       ` Vladimir Davydov [this message]
2019-03-27 10:23         ` Cyrill Gorcunov
2019-04-01 17:41           ` Cyrill Gorcunov
2019-04-01 18:58             ` Konstantin Osipov
2019-04-01 19:19               ` Cyrill Gorcunov
2019-04-01 20:51                 ` Konstantin Osipov
2019-04-01 22:05                   ` Cyrill Gorcunov
2019-04-02  7:14                     ` Konstantin Osipov
2019-04-02  8:09                       ` 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=20190327101552.d3b6xvezm3rigszm@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH 2/2] lib/core/fiber: Allow to extend 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