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 9340771814; Tue, 23 Feb 2021 03:17:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9340771814 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1614039474; bh=YIRU8NS4Drw+2II/FkioUQMHtpjcl/rDD34IMRi9b2Q=; 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=mj0j6beFM6qDeEaJYsdOx9E9Bxj/xSA77ib23U0YNJUhoxo9LVEe+dI1JA2cFVCpE 2QTvP1ramNIlEoTIG9c/ddxYCCvk0F0R+mSg80YJFnW0nX66F4Mzp0L63TRgo1OM2o XDhJWpy5pIU71ySL9EmsMPR2qWdKWOutfR+uiSQ8= Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 AB4D17185E for ; Tue, 23 Feb 2021 03:15:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org AB4D17185E Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1lELMl-0003CR-TJ; Tue, 23 Feb 2021 03:15:52 +0300 To: tarantool-patches@dev.tarantool.org, olegrok@tarantool.org, yaroslav.dynnikov@tarantool.org Date: Tue, 23 Feb 2021 01:15:40 +0100 Message-Id: <5530ed726e56702c79f70567c6e22f29eec32a8b.1614039039.git.v.shpilevoy@tarantool.org> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD975C3EC174F56692242B8E6687D03D8974314021AB65B8FCC182A05F53808504084D7FF938F53221D0619C4F4631B1422619E890CED4E4B0AC0B65DE4F4E94637 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F9D3BE5B596754B8C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE7A8325FA649D0A450EA1F7E6F0F101C674E70A05D1297E1BBC6CDE5D1141D2B1C047EB848B97AED270CC53FD6A9631009D2E54E697FB67FA89FA2833FD35BB23D9E625A9149C048EE26055571C92BF10FCB629EEF1311BF91D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BAA1C5B227563B4AFA471835C12D1D977C4224003CC836476EC64975D915A344093EC92FD9297F6718AA50765F7900637B8F435DEDE9E76EBA7F4EDE966BC389F395957E7521B51C24C7702A67D5C33162DBA43225CD8A89F0A35B161A8BF67C1262FEC7FBD7D1F5BB5C8C57E37DE458B4C7702A67D5C3316FA3894348FB808DB985633C00BAEBE4F574AF45C6390F7469DAA53EE0834AAEE X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C2115B036FF9F6D25D12CB8459C861819906905B9E6E80A1E9C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF1638054B7D09EC08699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34A1AF43396E40A36FB2DD4E0A4237CF50869D27ABC7783DF41F8453C7DFB85CB84522746E3DC3A5B61D7E09C32AA3244CAD8DE33B584FC80D761D3DCAFD2CE741B4DF56057A86259FFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj2drqE2xHc+HAQKCwuUuwmw== X-Mailru-Sender: 689FA8AB762F73936BC43F508A0638224B03B12FA7F2F0D62C81983E9369FE2B3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: [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: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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 -- 2.24.3 (Apple Git-128)