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 106D16EC57; Fri, 23 Jul 2021 14:11:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 106D16EC57 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1627038693; bh=f10WV4rb4EF62+Z6zYcSSb5z8KdiL721qAA6mhSDPPk=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=A5euyOVAnv6rT/5jYKxQlbPJMlwPhhbmAlDuhwuDIpVjHe8SCyVOIItsDKF2BUDZm tukU7NGKL9XihaqOCLYXZF7eoUfQ2XjMKHTktv2+Ef4btgheFDSpyHpUCbE/vjUfyj Wc2PfrnEXvNX2M2pyHe8+rr62GiCSpju/105+NhU= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (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 2450E6F3C9 for ; Fri, 23 Jul 2021 14:07:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2450E6F3C9 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1m6t1l-0004dl-JG; Fri, 23 Jul 2021 14:07:38 +0300 To: tarantool-patches@dev.tarantool.org Date: Fri, 23 Jul 2021 14:07:18 +0300 Message-Id: <121259670220eefee4a5dba03e6ab6f8db12f6d0.1627024646.git.vdavydov@tarantool.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD941C43E597735A9C3038391AAE5FBFA76FBCFDED1455B43CD182A05F538085040748B6F6F2A89BDB1023EA6AE76492A885FA070F43ABD1AAFE68C821B50727110 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE71840AE9AFD3F5D61C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE7DECE8D0A5E25C0FCEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BBCA57AF85F7723F2F574052F077386788392D95BF8DB2B07CC7F00164DA146DAFE8445B8C89999728AA50765F79006370BDB19F53EE528DD389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8A816C540FC8EEC30F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8B9149C560DC76099D75ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C16CF367659D795C016E38B21777411BB5473BF64BB62F1609C2B6934AE262D3EE7EAB7254005DCED68025756E0EE735792E1F3B950BCE21616EB5DE968479BF5B2CF3E77A3BD9B2CBDC6A1CF3F042BAD6DF99611D93F60EF4280523C145DA091699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34CAFBC0A7A4BEEE01543922AB34CB8E8A2A52A40B6031E9B2461FD6E7651EAAB2F5206A9036D8E4361D7E09C32AA3244CADD8CE32F90721BFEC0409E50631A6BA30363D8B7DA7DD44729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXiEX0g4jkpDtfd5MztBJujd X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DCEF58BDB5E59327B07FE70D9424E0D4B274CEFED1673C562683ABF942079399BFB559BB5D741EB966A65DFF43FF7BE03240331F90058701C67EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH 08/20] net.box: remove useless encode optimization 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: Vladimir Davydov via Tarantool-patches Reply-To: Vladimir Davydov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" luamp_encode copies its argument to the top of Lua stack unless it's already on the top so netbox_encode_{update,upsert} encode key/tuple and ops in reverse order to avoid the copy. There's no much point in it, because copying an argument in Lua stack costs nearly nothing - it's just a pointer copy. I ran a simple net.box test doing upserts and saw no difference with and without this optimization. Let's remove it, because it's easier to rewrite parts of net.box in C without it. --- src/box/lua/net_box.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/box/lua/net_box.c b/src/box/lua/net_box.c index ed1df4a189d2..8952efb7bb39 100644 --- a/src/box/lua/net_box.c +++ b/src/box/lua/net_box.c @@ -366,15 +366,13 @@ netbox_encode_update(lua_State *L) mpstream_encode_uint(&stream, IPROTO_INDEX_BASE); mpstream_encode_uint(&stream, 1); - /* encode in reverse order for speedup - see luamp_encode() code */ + /* encode key */ + mpstream_encode_uint(&stream, IPROTO_KEY); + luamp_convert_key(L, cfg, &stream, 5); + /* encode ops */ mpstream_encode_uint(&stream, IPROTO_TUPLE); luamp_encode_tuple(L, cfg, &stream, 6); - lua_pop(L, 1); /* ops */ - - /* encode key */ - mpstream_encode_uint(&stream, IPROTO_KEY); - luamp_convert_key(L, cfg, &stream, 5); netbox_encode_request(&stream, svp); return 0; @@ -402,16 +400,14 @@ netbox_encode_upsert(lua_State *L) mpstream_encode_uint(&stream, IPROTO_INDEX_BASE); mpstream_encode_uint(&stream, 1); - /* encode in reverse order for speedup - see luamp_encode() code */ - /* encode ops */ - mpstream_encode_uint(&stream, IPROTO_OPS); - luamp_encode_tuple(L, cfg, &stream, 5); - lua_pop(L, 1); /* ops */ - /* encode tuple */ mpstream_encode_uint(&stream, IPROTO_TUPLE); luamp_encode_tuple(L, cfg, &stream, 4); + /* encode ops */ + mpstream_encode_uint(&stream, IPROTO_OPS); + luamp_encode_tuple(L, cfg, &stream, 5); + netbox_encode_request(&stream, svp); return 0; } -- 2.25.1