From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Wed, 13 Mar 2019 17:17:24 +0300 From: Vladimir Davydov Subject: Re: [PATCH 3/3] lib/core/fiber: Put watermarks into stack to track its usage Message-ID: <20190313141724.wgt5xt3ey2shmtlo@esperanza> References: <20190312224721.8053-1-gorcunov@gmail.com> <20190312224721.8053-4-gorcunov@gmail.com> <20190313135204.x7gn54iqiy5ulavn@esperanza> <20190313140054.GO10420@uranus.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190313140054.GO10420@uranus.lan> To: Cyrill Gorcunov Cc: tml List-ID: 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.