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 4C5CD6EC55; Wed, 25 Aug 2021 23:34:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4C5CD6EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1629923671; bh=19pzeUvduPGkGT4clMON/fysAXb3QOXyu76FxVqiF8I=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=gJRcMU8hYh3q7fP8GwOaA7FaqdqAqNiPuT/qtczWKF7p00xqIgQcwyocHKODps7lV vZthpSiBKs79EU2qyxYXcsB8/EAG00IEIODkDJgsRunxK43Zzx3xKPayehWyHO9JxU 1hSexicZd1BvJM2Hmof4btydoRS93gm5uvm4Z8JA= 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 C48C96EC55 for ; Wed, 25 Aug 2021 23:34:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C48C96EC55 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mIzbQ-0007p7-QP; Wed, 25 Aug 2021 23:34:29 +0300 To: olegrok@tarantool.org, imun@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: <32b7ac476fec0b675b34d032a61326970491c7cf.1628713520.git.babinoleg@mail.ru> Message-ID: <9bcfb440-ae54-717c-e377-b49f134028f7@tarantool.org> Date: Wed, 25 Aug 2021 22:34:27 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <32b7ac476fec0b675b34d032a61326970491c7cf.1628713520.git.babinoleg@mail.ru> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD906AB4890CDABF0C5CB76CEE71D3E4007182A05F53808504039D41C72CCD56443D48F34BBADF228801B789E24D71DDD5ABB52A3846CC5CD12 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7AB524098FB2F2222EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637BC4B0F5721B555078638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D834CEAFFB945BA31E18DB7B5AE0FCCD0C117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC974A882099E279BDA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18CB629EEF1311BF91D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6A45692FFBBD75A6A089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B5055CD62E5931B804C3356F926830C2F45C X-C1DE0DAB: 0D63561A33F958A5DDC5FC45D4CA1640EC397300E6AC82D31A94ADFB74F3E379D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA753177526CD55AFC11410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34CA9B3B5DE5D383E6C16FD0D4973F7E698C6E1E0FA6DED3119652507B1AC273237B66A692FB0140D81D7E09C32AA3244C521901D87CA3C27C89423EB08F1C5CE851E887DA02A9F7BFFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojXSF/Tsl6M2Pg/7nm5fVjNw== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D25D54291A92F88C14AD0FFBEDE3BE8C63841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 4/4] fiber: allocate on_stop triggers using mempool 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" Thanks for the patch! See 4 comments below. On 11.08.2021 22:33, Oleg Babin via Tarantool-patches wrote: > From: Oleg Babin > > Previously we use malloc for such purpose however we created > on_stop triggers only if fiber storage was touched. Currently we > create on_stop trigger for each lua fiber. So it seems reasonable > to use mempool for such frequent allocations/deallocations. 1. Does it give any perf win? This commit specifically. Seems like an overkill. A trigger allocation might happen only once per fiber's lifetime, and the fiber's creation is supposed to be much longer than the trigger's malloc. The commit probably gives a tiny fraction of percent improvement or does not change anything. Do you have results? > diff --git a/src/lua/fiber.c b/src/lua/fiber.c > index 268ddf9cc..f7c0ca63f 100644 > --- a/src/lua/fiber.c > +++ b/src/lua/fiber.c > @@ -36,10 +36,19 @@ > #include "backtrace.h" > #include "tt_static.h" > > +#include 2. Please, use "" for non-system headers. > #include > #include > #include > > @@ -122,12 +131,13 @@ lbox_pushfiber(struct lua_State *L, struct fiber *f) > { > int ref = f->storage.lua.ref; > if (ref <= 0) { > - struct trigger *t = (struct trigger *)malloc(sizeof(*t)); > + struct trigger *t = mempool_alloc(&on_stop_triggers_pool);; > if (t == NULL) { > diag_set(OutOfMemory, sizeof(*t), "malloc", "t"); > luaT_error(L); > } > - trigger_create(t, lbox_fiber_on_stop, NULL, (trigger_f0) free); > + trigger_create(t, lbox_fiber_on_stop, NULL, > + on_stop_trigger_free); 3. Misalignment. > trigger_add(&f->on_stop, t); > > uint64_t fid = f->fid; > @@ -921,6 +931,9 @@ static const struct luaL_Reg fiberlib[] = { > void > tarantool_lua_fiber_init(struct lua_State *L) > { > + mempool_create(&on_stop_triggers_pool, &cord()->slabc, > + sizeof(struct trigger)); 4. Ditto. > + > luaL_register_module(L, fiberlib_name, fiberlib); > lua_pop(L, 1); > luaL_register_type(L, fiberlib_name, lbox_fiber_meta); >