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 1C2EA70201; Sat, 6 Mar 2021 01:03:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1C2EA70201 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1614981836; bh=OZoGxTGwqHzc26adYADdjYrSGVY9upl9XAzuAhieiC4=; 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=MVEXQ+ZRjLl+aNCrdKGfN7uJDjIGeIimqowfdVv2WNFK+NOETPxBd0K5zW5Xmayew d7iBlSUHAKYGAYg9tv8+scgXvqWAsmpzC1+mJ6qRnDnocAEn0AbyyE1EUp7nnjFXTf 8dZPfwxdKMAJJqjnwRUanA2A4SYjXLsmSKypnH60= Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [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 BD58670201 for ; Sat, 6 Mar 2021 01:03:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BD58670201 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lIIY5-0002LZ-GK; Sat, 06 Mar 2021 01:03:53 +0300 To: tarantool-patches@dev.tarantool.org, olegrok@tarantool.org, yaroslav.dynnikov@tarantool.org References: <259e9595aefe7a28af13eb6dd336ea8f145c2112.1612914070.git.v.shpilevoy@tarantool.org> Message-ID: <446bae55-fec7-9439-7bec-5d33f2c60d0c@tarantool.org> Date: Fri, 5 Mar 2021 23:03:52 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <259e9595aefe7a28af13eb6dd336ea8f145c2112.1612914070.git.v.shpilevoy@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9D3134714A9BDB69B844F3AC9255B388D8D4E2637BBED27E200894C459B0CD1B987459C866A83D84279485608E2ACAE758484C038DC1C3687680F0B1BC0C28F32 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE757E1881156861268EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637DC205F3977E1285D8638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95CFC18DCDA8D016604E4822B66ED201FC743F13D68119B0754A471835C12D1D9774AD6D5ED66289B5259CC434672EE6371117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE77A825AB47F0FC8649FA2833FD35BB23DF004C9065253843057739F23D657EF2B13377AFFFEAFD26923F8577A6DFFEA7C468D16C903838CAB93EC92FD9297F6715571747095F342E857739F23D657EF2BD5E8D9A59859A8B60149FEE6F00FA24375ECD9A6C639B01B4E70A05D1297E1BBC6867C52282FAC85D9B7C4F32B44FF57E8FBB06288C1946000306258E7E6ABB4E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A54DA64C3F84364E3B39930674CF6A9BF7A196A05C43BBC761D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34D4E96E2A5B1100E01B77717F50204F90FFB6FF381601D6B2B0B17E7D5D777075030F8479196BCA9A1D7E09C32AA3244C58225FB692101969EF0D69C67B641EBB55E75C8D0ED9F6EEFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojXmjzTEesUQHuhzqBtOPLVQ== X-Mailru-Sender: 689FA8AB762F73936BC43F508A0638222051F88C7990996F2C2EAC31242327BB3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 9/9] util: introduce binary heap data structure 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" Applied this diff and force-pushed, in order to eliminate the metatable and __index access. Besides, each heap's metatable is different from the others because the methods are closures, so there wouldn't be any memory saving from using a metatable. It couldn't have been shared between the heaps anyway. ==================== diff --git a/vshard/heap.lua b/vshard/heap.lua index 78c600a..b125921 100644 --- a/vshard/heap.lua +++ b/vshard/heap.lua @@ -203,22 +203,21 @@ local function heap_new(is_left_above) return count end - return setmetatable({ + return { -- Expose the data. For testing. data = data, - }, { - __index = { - push = heap_push, - update_top = heap_update_top, - remove_top = heap_remove_top, - pop = heap_pop, - update = heap_update, - remove = heap_remove, - remove_try = heap_remove_try, - top = heap_top, - count = heap_count, - } - }) + -- Methods are exported as members instead of __index so as to save on + -- not taking a metatable and going through __index on each method call. + push = heap_push, + update_top = heap_update_top, + remove_top = heap_remove_top, + pop = heap_pop, + update = heap_update, + remove = heap_remove, + remove_try = heap_remove_try, + top = heap_top, + count = heap_count, + } end return {