From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id C0A4C7030C; Mon, 24 May 2021 19:00:35 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C0A4C7030C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1621872035; bh=V0cP8+Csg/biBsDvtF7hir2gB1JTvFcSVkqJMytGbEg=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=qDr0n+R9Ns5B1A/zHnr3WFKxIjL0vEwvpOQd7G29883/79cWVfqWDci57aq2KRDnM FWe4qqZaunz/yQHYmz3pLOq4bhBrcDCW8ml08KeJG8Ta3JrRJfU6O1Ry6bNjNWrAoY XPwvU1a6GD9rvL37KGL8Cr/7CLnCi7qNM5qkVh1E= Received: from smtp57.i.mail.ru (smtp57.i.mail.ru [217.69.128.37]) (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 59CEA7030C for ; Mon, 24 May 2021 19:00:35 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 59CEA7030C Received: by smtp57.i.mail.ru with esmtpa (envelope-from ) id 1llD0M-0002m7-I2; Mon, 24 May 2021 19:00:34 +0300 To: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org, sergepetrenko@tarantool.org References: <2fb4c066558879eea74acab2e20b8a1c8f85d86b.1621778740.git.v.shpilevoy@tarantool.org> <6e775936-55ac-066e-c68f-743890f49a07@tarantool.org> <06d4c252-3f41-d91b-6943-ec4cca520a99@tarantool.org> Message-ID: <1daa20e1-0ff8-489d-cdb7-6515f7abe126@tarantool.org> Date: Mon, 24 May 2021 19:00:34 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <06d4c252-3f41-d91b-6943-ec4cca520a99@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD91B019B01C53E51AF113D6D562FBA72891FA115C4A817A10000894C459B0CD1B9D3C437E29FF7D6FFBE1A8C55EF27E25BCD5B426AFF7B2CB71AD6A186BD11839C X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7BF6702EC5472AA0FEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006377A7A7D315BEE81B48638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8CF53EC18185A6FDFEB77A3F90D417FDF117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD1828451B159A507268D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE7B96B19DC40933219935A1E27F592749D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE362B3BD3CC35DA588C0837EA9F3D19764C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637EC3198ECE464ADAEEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4AD8D3C131DB59ABB774803F0116D8B1204 X-C1DE0DAB: 0D63561A33F958A5ABA116D951D6C382F0B3DE8FB698D4CFA601EBE55D9561B4D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA753C350047980234DB410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34B5900AD87B4159A45A591F90A8F67BCBC4B12BB59EF9B972C85CB99DCE8F10E081377542610FB7C71D7E09C32AA3244CFE49620B6C38745D8DBBDC879CB47EC997FE24653F78E668FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj+gjVyQcIK6JxzQGZ+vUBgg== X-Mailru-Sender: 583F1D7ACE8F49BD07526C4546A62CBF618C9635DEB5D862F93B2C136BB4BE482A7001F21D2E138723E75C7104EB1B885DEE61814008E47C7013064206BFB89F93956FB04BA385BE9437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 1/1] json: use cord_ibuf for encoding and decoding X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Oleg Babin via Tarantool-patches Reply-To: Oleg Babin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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 > AFAIK. No, pcall in Lua is jitted (see http://wiki.luajit.org/NYI#libraries_base-library). But anyway I agree it gives huge overhead on hot paths.