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 C649F6FC87; Fri, 1 Oct 2021 01:39:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C649F6FC87 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1633041564; bh=uyZbsve5mBFYJ9iZSq+pLJkBqh5s5heMl9c7nkTExPo=; 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=GN3QKUwgL+GS6mdbUNe3H5CbM0G29/24zxcfMd66Yl94KYjvnvJJPlYxzv47mDOxY cQgbx4+2q4FM/OHniRCngiaUTUBSg1rPhb5+n4Gn2z45sczZ1IdI+bggKqmh9Jy3JB 6IHiJi0vI7zEx21jZkrx476Uf7forSJLdYHefgJ4= Received: from smtpng3.i.mail.ru (smtpng3.i.mail.ru [94.100.177.149]) (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 CA2C46FC87 for ; Fri, 1 Oct 2021 01:39:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CA2C46FC87 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1mW4i3-0008Iv-0c; Fri, 01 Oct 2021 01:39:23 +0300 To: Oleg Babin , tarantool-patches@dev.tarantool.org References: <6f2babce-b5eb-ecd3-394b-29486e56dbdb@tarantool.org> Message-ID: <2787659c-f3fc-7552-6762-9fa78f883764@tarantool.org> Date: Fri, 1 Oct 2021 00:39:22 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <6f2babce-b5eb-ecd3-394b-29486e56dbdb@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD96A58C36AA2E996499DED20B83AFF2DE90C450EFC080BE8B7182A05F5380850404DB6B223B05237607257C540909F39ABF85E8D810CE91680ABF0346CBC0C43C3 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7E50EC9128971FD6EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006370FDF1CE57EA9D07C8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D82A8A3FA5586F860BA828E6F9E31C8F93117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18BDFBBEFFF4125B51D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B613439FA09F3DCB32089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B50578E062FC77F06504485914473EC27227 X-C1DE0DAB: 0D63561A33F958A5599D17FE3D3B256D807840D3053B7F1895361F0EB0C6F225D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA757AF5085B7B0228D6410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D341B5517184E88C1BD478E8B6025AE62D21F77639C5721143D7A1A0B83CAD47B80C4974F0B39598AF21D7E09C32AA3244C8CDB2C3D21C853096AA8052106846B56A8CE788DE6831205729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojJNmX3owDPmFTvvJE1/UmCA== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DD5B2832ADBC776C68F72919C77C57E9F3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH vshard 1/2] router: wrap is_async futures completely 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 review! On 29.09.2021 08:18, Oleg Babin wrote: > Thanks for your patch! I left three comments below. > > On 29.09.2021 02:08, Vladislav Shpilevoy wrote: >> Router used to override :result() method of netbox futures. It is >> needed because user functions are called via vshard.storage.call() >> which returns some metadata - it must be truncated before >> returning the user's data. >> >> It worked fine while netbox futures were implemented as tables. >> But in the newest Tarantool most of netbox state machine code is >> moved into C. The futures now are cdata. > AFAIK userdata (not cdata) if it makes sense. Changed to 'C structs'. >> diff --git a/vshard/router/init.lua b/vshard/router/init.lua >> index 3d468f3..42de740 100644 >> --- a/vshard/router/init.lua >> +++ b/vshard/router/init.lua >> @@ -470,6 +470,114 @@ end >>   -- API >>   -------------------------------------------------------------------------------- >>   > > I thing following changes could be moved into sepearate file. I thought of that, but decided it won't improve much. These futures are a part of router_call, they can't be used for anything else. Because are specific to how the storage answers to router_call. They won't work for replicaset:call() nor for router_map_callrw() So by moving them out I won't make it easier to reuse them or make them more independent. I will just reduce init.lua file size, which is not a primary goal. I was rather hoping to move the entire router_call() into its own file eventually with all its satellite structures and functions used only by it. Does it make sense? >> +local function vshard_future_tostring(self) >> +    return 'vshard.net.box.request' >> +end >> + >> +local function vshard_future_serialize(self) >> +    -- Drop the metatable. It is also copied and if returned as is leads to >> +    -- recursive serialization. >> +    local s = setmetatable(table.deepcopy(self), {}) >> +    s._base = nil >> +    return s >> +end >> + >> +local function vshard_future_is_ready(self) >> +    return self._base:is_ready() >> +end >> + >> +local function vshard_future_wrap_result(res) >> +    local storage_ok, res, err = unpack(res) > > Unpack could be replaced with ... = res[1], res[2], res[3]. > > Should be a bit faster since unpack can't be jitted. Nice, didn't know that. ==================== diff --git a/vshard/router/init.lua b/vshard/router/init.lua index 42de740..4748398 100644 --- a/vshard/router/init.lua +++ b/vshard/router/init.lua @@ -487,7 +487,7 @@ local function vshard_future_is_ready(self) end local function vshard_future_wrap_result(res) - local storage_ok, res, err = unpack(res) + local storage_ok, res, err = res[1], res[2], res[3] if storage_ok then if res == nil and err ~= nil then return nil, lerror.make(err)