From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id C5A5F46970E for ; Thu, 30 Jan 2020 08:46:42 +0300 (MSK) References: <20200123084445.7452-1-skaplun@tarantool.org> <290fd1a1-022d-d0cf-d823-df6008872029@tarantool.org> <20200129133609.GD547@tarantool.org> From: Leonid Vasiliev Message-ID: <82333230-a66a-0ae0-f57b-f9ab930b4608@tarantool.org> Date: Thu, 30 Jan 2020 08:46:40 +0300 MIME-Version: 1.0 In-Reply-To: <20200129133609.GD547@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH v2] refactoring: drop excess 16Kb bss buffer List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Ostanevich , Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org Hi. On 1/29/20 4:36 PM, Sergey Ostanevich wrote: > Hi! > > Thanks for the patch! > > LGTM after updates below. > > Regards, > Sergos > > > On 23 Jan 23:04, Vladislav Shpilevoy wrote: >> Hi! Thanks for the patch! >> >> I agree with everything what Leonid said. > > I will object both assertion and NULL handling. Just have a look: > >>> + char *backtrace_buf = (char *)static_alloc(SMALL_STATIC_SIZE); > > And in static_reserve(size_t size) called from static_alloc(): > > if (size > SMALL_STATIC_SIZE) > return NULL; > > is the only place NULL can be returned. No need to test if > SMALL_STATIC_SIZE > SMALL_STATIC_SIZE, just ask me :) Hmm, it's sounds like:"Client must known about implementation of library function". But implementation can be changed with the contract save. > > > >> >> On 23/01/2020 09:44, Sergey Kaplun wrote: >>> We already have 12Kb thread-safe static buffer >>> in `lib/small/small/static.h`, that can be used instead of 16Kb >>> bss buffer in `src/lib/core/backtrace.cc` for backtrace payload. >>> Closes #4650 >>> --- >>> >>> branch: https://github.com/tarantool/tarantool/tree/skaplun/drop-bss-buff >>> issue: https://github.com/tarantool/tarantool/issues/4650 >>> >>> src/lib/core/backtrace.cc | 8 +++++--- >>> 1 file changed, 5 insertions(+), 3 deletions(-) >>> >>> diff --git a/src/lib/core/backtrace.cc b/src/lib/core/backtrace.cc >>> index 77f77b05c..c70576b53 100644 >>> --- a/src/lib/core/backtrace.cc >>> +++ b/src/lib/core/backtrace.cc >>> @@ -33,6 +33,7 @@ >>> >>> #include >>> #include >>> +#include >>> >>> #include >>> >>> @@ -47,6 +48,7 @@ >>> #include >>> >>> #include "small/region.h" >>> +#include "small/static.h" >>> /* >>> * We use a global static buffer because it is too late to do any >>> * allocation when we are printing backtrace and fiber stack is > > Just change "global static buffer" for the "static buffer interface". > >>> @@ -55,8 +57,6 @@ >>> >>> #define BACKTRACE_NAME_MAX 200 >>> >>> -static char backtrace_buf[4096 * 4]; >>> - >>> static __thread struct region cache_region; >>> static __thread struct mh_i64ptr_t *proc_cache = NULL; >>> >>> @@ -140,8 +140,10 @@ backtrace() >>> unw_getcontext(&unw_context); >>> unw_cursor_t unw_cur; >>> unw_init_local(&unw_cur, &unw_context); >>> + char *backtrace_buf = (char *)static_alloc(SMALL_STATIC_SIZE); >>> + assert(backtrace_buf); >>> char *p = backtrace_buf; >>> - char *end = p + sizeof(backtrace_buf) - 1; >>> + char *end = p + SMALL_STATIC_SIZE - 1; >>> int unw_status; >>> *p = '\0'; >>> while ((unw_status = unw_step(&unw_cur)) > 0) { >>>