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 6C1C46FC85; Fri, 3 Sep 2021 15:48:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6C1C46FC85 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1630673311; bh=Ip/h+RF3UoDU+5xuufQXVgAMlg74EpMZjxQkCpBmM9c=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=BCPUV4tJ+nLgg6+TofJy9vsOB4jApw/a5Pky1zwe/aX1gBBp4q9TVkO0zaDNFN3et u88n6DI2cCHTUnQqGyjLHYfwHuLbjNwC65tLuN/KjtnLhTXQWjsDBCVZx0I9ToVsap R4PLMIKQIuaa1NSb/Ny9OIkFfmgMAm/K0iwefCjk= 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 F1CA86FC85 for ; Fri, 3 Sep 2021 15:48:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F1CA86FC85 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mM8cO-0002eA-CM; Fri, 03 Sep 2021 15:48:28 +0300 Date: Fri, 3 Sep 2021 15:23:14 +0300 To: olegrok@tarantool.org Message-ID: <20210903122314.GV5743@tarantool.org> References: <7ef7fcfec0d2c78721ea17376cbfe0d0f231798c.1630606077.git.babinoleg@mail.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <7ef7fcfec0d2c78721ea17376cbfe0d0f231798c.1630606077.git.babinoleg@mail.ru> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.10.1 (2018-07-13) X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9D96C1EA41D18F4D5D354789DDBD713C098C562D0F83B1E74182A05F538085040B0E947DB7A0E7CC7631A23BA217CB87E4304C39E3D0ACBDDEF9F4B9175BA09CA X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7544B1CCE26E01C74EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063725FA9CD6081C82518638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8818E6A8FEB26E8AAB834D5D99CEC6BDE117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAE9A1BBD95851C5BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751F6FD1C55BDD38FC3FD2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6BF3059D42242344A089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A591F28F0DDBE8889B1BD79D9DECADA5DAD5F6075F7B4DF49AD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA752546FE575EB473F1410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34BF5454112BD5BFD72F47F68616904D4C62462191AFD2FD60E64E76FF03F6734B34E2255A33593C401D7E09C32AA3244C5C1DA83379FFE060F6B00FB1DFF8C52C853296C06374E60283B48618A63566E0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioja9FuITQvsRqPbYWmxkDl/w== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D87EF27A2745901321F9433D2C7CD48FCA7C8D0F45F857DBFE9F1EFEE2F478337FB559BB5D741EB964C8C2C849690F8E70A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 3/3] fiber: keep reference to userdata if fiber created once 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: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Oleg, Thanks for the fixes! I still have some comments regarding the new version of this patch. On 02.09.21, olegrok@tarantool.org wrote: > From: Oleg Babin > > This patch reworks approach to fiber management in Lua. Before > this patch each action that should return fiber led to new > userdata creation that was quite slow and made GC suffer. This > patch introduces new field in struct fiber to store a reference to > userdata that was created once for a fiber. It allows speedup > operations as fiber.self() and fiber.id(). > Simple benchmark shows that access to fiber storage is faster in > two times, fiber.find() - 2-3 times and fiber.new/create functions > don't have any changes. > --- > src/lib/core/fiber.c | 5 ++ > src/lib/core/fiber.h | 5 ++ > src/lua/fiber.c | 113 +++++++++++++------------------------------ > 3 files changed, 44 insertions(+), 79 deletions(-) > > diff --git a/src/lib/core/fiber.c b/src/lib/core/fiber.c > index 588b78504..39b67f940 100644 > --- a/src/lib/core/fiber.c > +++ b/src/lib/core/fiber.c > @@ -32,6 +32,7 @@ > > #include > #include > +#include Totally agree with Vlad here. I guess you have two options: * Use the approach similar to . * Introduce a constant in src/lib/core/fiber.h and add a static assert in src/lua/utils.h whether this value is the same as in LuaJIT. Maybe there are other options Vlad can suggest. > #include > #include > #include > diff --git a/src/lua/fiber.c b/src/lua/fiber.c > index 5575f2079..ab0e895eb 100644 > --- a/src/lua/fiber.c > +++ b/src/lua/fiber.c > @@ -87,27 +87,28 @@ luaL_testcancel(struct lua_State *L) > + struct fiber *f = event; > + int storage_ref = f->storage.lua.storage_ref; Minor: Why do you need both and variables? After your change they can be freely dropped. > + luaL_unref(tarantool_L, LUA_REGISTRYINDEX, storage_ref); > + f->storage.lua.storage_ref = LUA_NOREF; > + int ref = f->storage.lua.fid_ref; > + luaL_unref(tarantool_L, LUA_REGISTRYINDEX, ref); > + f->storage.lua.fid_ref = LUA_NOREF; > + trigger_clear(trigger); > + free(trigger); > + return 0; > } > > /** > @@ -116,42 +117,26 @@ lbox_create_weak_table(struct lua_State *L, const char *name) > + int ref = f->storage.lua.fid_ref; Minor: It would be nice also to rename to . > + if (ref == LUA_NOREF) { > -- > 2.32.0 > -- Best regards, IM