From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp42.i.mail.ru (smtp42.i.mail.ru [94.100.177.102]) (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 CDEC04765E0 for ; Fri, 25 Dec 2020 00:21:22 +0300 (MSK) Date: Fri, 25 Dec 2020 00:20:37 +0300 From: Sergey Kaplun Message-ID: <20201224212037.GM9101@root> References: <0adaa12ef5be0efc1d9c79ab746b8149c252d661.1608142899.git.skaplun@tarantool.org> <20201221092415.GT5396@tarantool.org> <20201224064656.GH9101@root> <4216B30D-84B1-4A46-8DD7-C1A51587D7FF@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4216B30D-84B1-4A46-8DD7-C1A51587D7FF@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH luajit v1 03/11] profile: introduce profiler writing module List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Ostanevich Cc: tarantool-patches@dev.tarantool.org On 24.12.20, Sergey Ostanevich wrote: > Hi! > > Thanks for the changes. Although I see no new patch - I look into the > origin/skaplun/gh-5442-luajit-memory-profiler under third_party/luajit Yes, I'm adding some updates relating to Igor's review for RFC, naming and commit messages. > > +void lj_wbuf_init(struct lj_wbuf *buf, lj_wbuf_writer writer, void *ctx, > + uint8_t *mem, size_t size) > +{ > + lua_assert(size >= LEB128_U64_MAXSIZE); > > Is it meaningful to allocate just 10bytes? No, but at least we should check it. We need at least 10bytes buffer to write huge addresses leb128-encoded. > > +/* Writes n bytes from an arbitrary buffer src to the buffer. */ > +void lj_wbuf_addn(struct lj_wbuf *buf, const void *src, size_t n) > +{ > + if (LJ_UNLIKELY(lj_wbuf_test_flag(buf, STREAM_STOP))) > + return; > + /* > + ** Very unlikely: We are told to write a large buffer at once. > + ** Buffer not belong to us so we must to pump data > + ** through buffer. > + */ > + while (LJ_UNLIKELY(n > buf->size)) { > + const size_t left = wbuf_left(buf); > + memcpy(buf->pos, src, left); > > I’m afraid the src pointer is not progress through the while() loop Thank you very much! Nice catch! Fixed. > > > + buf->pos += (ptrdiff_t)left; > + lj_wbuf_flush(buf); > + n -= left; > + } > > > Sergos. > > > -- Best regards, Sergey Kaplun