[RFC v3] fiber: Increase default stack size
vdavydov.dev at gmail.com
Tue Feb 26 15:34:56 MSK 2019
On Tue, Feb 26, 2019 at 02:16:32PM +0300, Cyrill Gorcunov wrote:
> > - 1 MB for max stack size seems to be a bit of an overkill for now.
> > The default value should be set to 256 KB, but we do need a
> > configuration option for it. Let's add it to the fiber Lua module.
> > May be done in a separate patch, but should be submitted together in
> > the same patch set.
> Wait, first fiber for main cord is created before lua init, isn't it?
> I already though about using lua config for it but fiber init'ed at
> very early stage.
Yeah, good point, I haven't thought about it. Then we have to either
always allocate a big stack for the main fiber or use an environment
variable. Let's get back to it later and first make the stack size limit
> > - 16 byte unique identifier for detecting stack overflow doesn't seem
> > to be enough. Imagine a PATH_MAX buffer allocated on stack that uses
> > only a hundred bytes for path formatting. It can easily jump over the
> > watermark. We should probably use random poisoning: say, 4 unique
> > identifiers 8 bytes each scattered a few hundred bytes apart. Some
> > math/reasoning behind this would be nice to see in the comments.
> If we want to scatter we should simply put marks at page bounds.
> Dirtifying somewhere inside middle of a page is useless.
Hmm, why? Consider the example with PATH_MAX buffer. Putting dirty marks
at page boundaries doesn't guarantee any of them will get overwritten by
the buffer if only a few hundred of bytes are used. I think we should
dirty the last page or two at random intervals - this should increase
the chance that at least one mark is overwritten by any function that is
eager for the stack.
More information about the Tarantool-patches