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 B24EF6EC58; Mon, 21 Jun 2021 23:36:17 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B24EF6EC58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1624307777; bh=aZZtIh80WBmxG4QtwTnA4XSpS03F3lPIr3bhyspdI2s=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=czPnGYxJ8+o4Q4KPji6B9VpXUWLUMs9btzLcQuytRToURo0lnqPyMTjMT75xGmdLh Zz64za4F0msHX0aOs1GxVbn0PDnaA5/v1x21ktZchU8HX5e/X/7OILxzijsO/IeJ/J ptv9283vEcu+bqA0UxGavqRuhlKyAlrlHiSoS3bI= 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 13CAB6EC58 for ; Mon, 21 Jun 2021 23:36:13 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 13CAB6EC58 Received: by smtp57.i.mail.ru with esmtpa (envelope-from ) id 1lvQeS-0000qG-0N; Mon, 21 Jun 2021 23:36:12 +0300 To: Sergey Kaplun , Igor Munkin Cc: tarantool-patches@dev.tarantool.org References: <20210618181416.25454-1-skaplun@tarantool.org> Message-ID: <67687e87-fb0e-1477-ac76-5fa9b04b9e3a@tarantool.org> Date: Mon, 21 Jun 2021 22:36:10 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210618181416.25454-1-skaplun@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD91C2C07775F13263A65B2A0865841DD232D6C915D49D3808000894C459B0CD1B96F32DA1F5655DA3A077E88C016BA44FABAD38EBFFE3ECEA3F649426FA9741B02 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7A3295C83650092F9EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B28E90C11C329EF18638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8D77A16850D2FE29496BFD72926C7B6DE117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC8C7ADC89C2F0B2A5A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18E5D25F19253116ADD2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE4B6963042765DA4B8F49F126DDB898E8D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE3A7DFDF579AB090EF2D242C3BD2E3F4C6C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637B8F435DEDE9E76EBEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4AD9DE205CAC1902202D6285BFFF6692FD9 X-C1DE0DAB: 0D63561A33F958A5FC4EB520518171BBB9DDEC7E9758BC112776D3810DAB9BDED59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D349A949488F6BF46DDB6FD128DFA73C2BDE3A4E1A565C9BDD814FDFA16A6C328F5C828D32C6049DD1E1D7E09C32AA3244C78DEAEBAE53E9101D473E77FC745822269B6CAE0477E908DFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojrAWM8Mt/TOBQsxZUS6cPuw== X-Mailru-Sender: 504CC1E875BF3E7D9BC0E5172ADA3110CF3489AE5CA151EF3DF7DCE1CE2B148C307B5A32C6BFE16407784C02288277CA03E0582D3806FB6A5317862B1921BA260ED6CFD6382C13A6112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH] lua: refactor port_lua_do_dump and encode_lua_call 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: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! Thanks for the patch! > Branch: https://github.com/tarantool/tarantool/tree/skaplun/gh-noticket-refactor-lua-call > See the benchmarks sources here [1]. > > Before patch: > | Encode map: 189851357 mcs, 15.8 K ps > | Encode seq: 187926351 mcs, 16.0 K ps > | Encode str: 185451675 mcs, 16.2 K ps > | Encode dig: 184833396 mcs, 16.2 K ps > > After patch: > | Encode map: 187814261 mcs, 16.0 K ps > | Encode seq: 183755028 mcs, 16.3 K ps > | Encode str: 181571626 mcs, 16.5 K ps > | Encode dig: 181572998 mcs, 16.5 K ps > > Looks like the perf doesn't degrade at least. > > [1]: https://gist.github.com/Buristan/3e6d6bf2c722874bec55a8c5a44b98f3 > > src/box/lua/call.c | 71 ++++++++++++++++++++++++++++++++++++---------- > 1 file changed, 56 insertions(+), 15 deletions(-) > > diff --git a/src/box/lua/call.c b/src/box/lua/call.c > index 0315e720c..3b2572096 100644 > --- a/src/box/lua/call.c > +++ b/src/box/lua/call.c > @@ -450,13 +482,20 @@ port_lua_do_dump(struct port *base, struct mpstream *stream, > struct encode_lua_ctx ctx; > ctx.port = port; > ctx.stream = stream; > - struct lua_State *L = tarantool_L; > - int top = lua_gettop(L); > - if (lua_cpcall(L, handler, &ctx) != 0) { > - luaT_toerror(port->L); > + lua_State *L = port->L; > + /* > + * At the moment Lua stack holds only values to encode. > + * Insert corresponding encoder to the bottom and push > + * encode context as lightuserdata to the top. > + */ > + const int size = lua_gettop(L); > + lua_rawgeti(L, LUA_REGISTRYINDEX, execute_lua_refs[handler]); > + assert(lua_isfunction(L, -1) && lua_iscfunction(L, -1)); > + lua_insert(L, 1); If I remember correctly, this leads to moving all the existing stack elements forward. Which might be expensive. I know from Vlad Grubov's words that they have code with hundreds of values in multireturn from stored functions. Did you bench what happens when the Lua coroutine contains a lot of values? In the bench by the link above I see only 1-element array and map. Size of the array and map does not matter though. Only multireturn is interesting here. Like 'return 1, 2, 3, ...'.