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 5D0B67030D; Wed, 24 Feb 2021 13:27:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5D0B67030D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1614162470; bh=i4BJA59GAYrNtzpc5ckBF+5e7BtO5y69Wqg5rBgFcoU=; 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=w3hsTVsubCudEhJtTtqBolm57mge7myqYE2prLR2Vbo2BrCbXRuIxwycrKdScSDUP GVpfVYA+6Nudy5JlGID9GqPr21ypj7XSm5nd3+ZuA2WS3nI3dVn4TofvjNb6DTocWp NJTzAsL1Jj/jCH9EvoDCqg7G9M5xDhj8y4oMTVfo= Received: from smtp42.i.mail.ru (smtp42.i.mail.ru [94.100.177.102]) (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 D90767030D for ; Wed, 24 Feb 2021 13:27:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D90767030D Received: by smtp42.i.mail.ru with esmtpa (envelope-from ) id 1lErO9-0008B4-5n; Wed, 24 Feb 2021 13:27:25 +0300 To: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org, yaroslav.dynnikov@tarantool.org References: <5530ed726e56702c79f70567c6e22f29eec32a8b.1614039039.git.v.shpilevoy@tarantool.org> Message-ID: <6368c441-d22b-b20a-541e-1b5f7ac7622c@tarantool.org> Date: Wed, 24 Feb 2021 13:27:24 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <5530ed726e56702c79f70567c6e22f29eec32a8b.1614039039.git.v.shpilevoy@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD975C3EC174F56692242B8E6687D03D8974314021AB65B8FCC182A05F53808504084182FE53BF57E95CC081DF355FBEA0813654BFE97E89BDB602A9E93821D18C2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7548C33FFD72831AFEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063745476ED688D943148638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FC37516A87862161418BE840B94C002DA24A5A904413F0DBED389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0C26CFBAC0749D213D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B081CF0AE924DC023A471835C12D1D977C4224003CC836476EB9C4185024447017B076A6E789B0E975F5C1EE8F4F765FC6A03BDC6CE4C620F3AA81AA40904B5D9CF19DD082D7633A078D18283394535A93AA81AA40904B5D98AA50765F79006376382E7E2B5934095D81D268191BDAD3D698AB9A7B718F8C442539A7722CA490C13377AFFFEAFD26923F8577A6DFFEA7CB59C7783CC88FA9693EC92FD9297F6715571747095F342E857739F23D657EF2BD5E8D9A59859A8B655EC1579764E9EAF089D37D7C0E48F6C5571747095F342E857739F23D657EF2B6825BDBE14D8E7028C9DFF55498CEFB0BD9CCCA9EDD067B1EDA766A37F9254B7 X-C1DE0DAB: 0D63561A33F958A5673A7ECCB5AB8F0E59A6B596F964E8B21986A47CE811989FD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75B7BFB303F1C7DB4D8E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34047E322BFAFD69BDD2229E726D4BCCA30F0BF5E4538BD850DE7CB362C6CB4B64095B07E75522D3A71D7E09C32AA3244C58A4F989DF334CA059E38E61C404C43F4DBEAD0ED6C55A80FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojyK6JYJ15DtJbJMn5TirWbA== X-Mailru-Sender: 583F1D7ACE8F49BD9317CE1922F30C7E375BD854618A0014EE0C17995B284E22795016C701673FFF23E75C7104EB1B885DEE61814008E47C7013064206BFB89F93956FB04BA385BE9437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH vshard 02/11] storage: add helper for local functions invocation 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" Hi! Thanks for your patch. LGTM. On 23.02.2021 03:15, Vladislav Shpilevoy wrote: > Function local_call() works like netbox.self.call, but is > exception-safe, and uses cached values of 'netbox.self' and > 'netbox.self.call'. This saves at least 3 indexing operations, > which are not free as it appeared. > > The cached values are not used directly in storage_call(), because > local_call() also will be used from the future function > storage_map() - a part of map-reduce API. > > Needed for #147 > --- > vshard/storage/init.lua | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/vshard/storage/init.lua b/vshard/storage/init.lua > index e0ce31d..a3d383d 100644 > --- a/vshard/storage/init.lua > +++ b/vshard/storage/init.lua > @@ -6,6 +6,8 @@ local trigger = require('internal.trigger') > local ffi = require('ffi') > local yaml_encode = require('yaml').encode > local fiber_clock = lfiber.clock > +local netbox_self = netbox.self > +local netbox_self_call = netbox_self.call > > local MODULE_INTERNALS = '__module_vshard_storage' > -- Reload requirements, in case this module is reloaded manually. > @@ -171,6 +173,16 @@ else > bucket_ref_new = ffi.typeof("struct bucket_ref") > end > > +-- > +-- Invoke a function on this instance. Arguments are unpacked into the function > +-- as arguments. > +-- The function returns pcall() as is, because is used from places where > +-- exceptions are not allowed. > +-- > +local function local_call(func_name, args) > + return pcall(netbox_self_call, netbox_self, func_name, args) > +end > + > -- > -- Trigger for on replace into _bucket to update its generation. > -- > @@ -2275,7 +2287,7 @@ local function storage_call(bucket_id, mode, name, args) > if not ok then > return ok, err > end > - ok, ret1, ret2, ret3 = pcall(netbox.self.call, netbox.self, name, args) > + ok, ret1, ret2, ret3 = local_call(name, args) > _, err = bucket_unref(bucket_id, mode) > assert(not err) > if not ok then