Tarantool development patches archive
 help / color / mirror / Atom feed
From: Oleg Babin via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>,
	tarantool-patches@dev.tarantool.org, sergepetrenko@tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 1/1] json: use cord_ibuf for encoding and decoding
Date: Mon, 24 May 2021 19:00:34 +0300	[thread overview]
Message-ID: <1daa20e1-0ff8-489d-cdb7-6515f7abe126@tarantool.org> (raw)
In-Reply-To: <06d4c252-3f41-d91b-6943-ec4cca520a99@tarantool.org>

Thanks for your explanation. LGTM.

I put several comments below.

On 24.05.2021 18:49, Vladislav Shpilevoy wrote:
> Hi! Thanks for the review!
> On 24.05.2021 12:04, Oleg Babin wrote:
>> Hi! Thanks for your patch.
>> I see strange effect. After a patch following script:
>> ```
>> for i = 1, 1e9 do pcall(json.encode, function() end) end
>> ```
>> produces quite strange effects with memory. After some time
>> my system kills a process - also I see in htop that process consumes about 20% of memory.
>> In contrast before the patch process uses 0.1% of memory and doesn't have any oscillations
>> in "VIRT" and "RES" columns. Yes, it's a negative case but I believe such behaviour shouldn't be affected as well.
> This is happening because you didn't do any yields. Cord buffer is freed
> automatically when a yield happens. This is a workaround for not being
> able to use a global buffer, which wouldn't need freeing at all.

After your explanation my comment looks irrelevant. Agree, in real projects

it's impossible to run code without any yields. Thanks!

> This is a known issue with the cord buffer, and the only working alternative
> I see is to wrap all related Lua C calls into lua_pcall(). This leads to
> perf issues for the success case, because pcall does more work; because
> you usually need to re-push the arguments; and because pcall is not jitted

No, pcall in Lua is jitted (see 

But anyway I agree it gives huge overhead on hot paths.

  reply	other threads:[~2021-05-24 16:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-23 14:06 Vladislav Shpilevoy via Tarantool-patches
2021-05-24 10:04 ` Oleg Babin via Tarantool-patches
2021-05-24 15:49   ` Vladislav Shpilevoy via Tarantool-patches
2021-05-24 16:00     ` Oleg Babin via Tarantool-patches [this message]
2021-05-24 13:01 ` Serge Petrenko via Tarantool-patches
2021-05-24 13:05   ` Serge Petrenko via Tarantool-patches
2021-05-24 15:47     ` Vladislav Shpilevoy via Tarantool-patches
2021-05-24 15:47   ` Vladislav Shpilevoy via Tarantool-patches
2021-05-24 16:17     ` Serge Petrenko via Tarantool-patches
2021-05-25 21:20 ` Vladislav Shpilevoy via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1daa20e1-0ff8-489d-cdb7-6515f7abe126@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=olegrok@tarantool.org \
    --cc=sergepetrenko@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 1/1] json: use cord_ibuf for encoding and decoding' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox