[PATCH 3/3] lib/core/fiber: Put watermarks into stack to track its usage

Vladimir Davydov vdavydov.dev at gmail.com
Wed Mar 13 17:17:24 MSK 2019


On Wed, Mar 13, 2019 at 05:00:54PM +0300, Cyrill Gorcunov wrote:
> > > +
> > > +	if (!stack_has_wmark(fiber->stack_overflow_wmark)) {
> > > +		say_warn("stack usage is close to the limit of %zu bytes",
> > > +			 (size_t)FIBER_STACK_SIZE_DEFAULT);
> > 
> > IMO warning only when we are close to the limit isn't very useful.
> > Let's keep track of the max stack size instead and print it whenever
> > it's increased.
> 
> Could you please elaborate. I don't understand what you mean by
> keep tracking of max stack size. You propose to remember somewhere
> if this mark has been vanished?

Yeah, keep track of the max recorded stack size in a static variable
and keep advancing the higher watermark position whenever it gets
overwritten so that we can report max stack size used:

  I> max stack size is 73728 bytes
  ...
  I> max stack size is 112640 bytes

(the wording might need polishing)

> > > @@ -927,8 +1090,12 @@ cord_create(struct cord *cord, const char *name)
> > >  	/* Record stack extents */
> > >  	tt_pthread_attr_getstack(cord->id, &cord->sched.stack,
> > >  				 &cord->sched.stack_size);
> > > +	cord->sched.stack_overflow_wmark = cord->sched.stack;
> > > +	cord->sched.stack_shrink_wmark = cord->sched.stack;
> > 
> > I don't think we need to set the watermarks for the sched fiber,
> > even if ASAN is on.
> 
> Won't they left unitialized then? The only reason I put nils here
> is to force them have known values even if they are unused.

I'd set them to NULLs for both cases, i.e. outside ifdef.



More information about the Tarantool-patches mailing list