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 121B76DB0B; Thu, 30 Jun 2022 15:19:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 121B76DB0B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1656591562; bh=LVox5Lv4HPhws5x2nb66QHWkG4BawRF7LyEkgURUCFM=; 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=LqgmQSbFftcL3dIQ3S4YFW0E90KIatai1yhRpNUAx09Cwm6mudyCN3FBu+ZbKTEm/ /1oACw+V+V10GRD3941i2zEYIRuiwXmrud0K5Ph57rQHKOxB71Uu7lotQZSy3WJBWH G9uVL2e1YmtdCFze6XTHw8ymf7KGfmYL/gF1qDnk= Received: from smtpng2.i.mail.ru (smtpng2.i.mail.ru [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 8A5EC6DB0D for ; Thu, 30 Jun 2022 15:17:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8A5EC6DB0D Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1o6t71-0005v1-MY; Thu, 30 Jun 2022 15:17:36 +0300 Date: Thu, 30 Jun 2022 15:10:24 +0300 To: Sergey Kaplun Message-ID: References: <20220606133528.13355-1-skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220606133528.13355-1-skaplun@tarantool.org> X-Clacks-Overhead: GNU Terry Pratchett X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9F05DDD76985F9126E1DDAE1C6EB0772846459A7F84F1DAA6182A05F5380850404107B0413756A4F5F8FB6758548381548D61DCD1EC95C583176C3ED52907920B X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F544D30F1A6FA191EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006375121C8F3070B83748638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8AC01AA534CC54CF063477FE63898FA7C117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B8C7ADC89C2F0B2A5A471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C837C4FEFBD186071C4224003CC83647689D4C264860C145E X-8FC586DF: 6EFBBC1D9D64D975 X-C1DE0DAB: 9604B64F49C60606AD91A466A1DEF99B296C473AB1E14218C6CDE5D1141D2B1C63EBED25B40ECB4C5684CB89217692B48380AECBBD111CD6AD91A466A1DEF99B296C473AB1E14218B936CB490224F2464EEA7BD89490CAC0EDDA962BC3F61961 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34EA882B598A209811DCDBA166D0670641CE201E0EE9DC1568C56D6AEC7A0EDC3A1FA649E77D1F75A11D7E09C32AA3244CD3AAE3B63F59A1E2777ED0F613031BA19CA7333006C390A0927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojhvrbUd41KJkDqfjUYbsulg== X-Mailru-Sender: 689FA8AB762F7393CC2E0F076E87284E2AE96DD9FA07E6F00295B33896A07B3CA7C8D0F45F857DBFE9F1EFEE2F478337FB559BB5D741EB964C8C2C849690F8E70A04DAD6CC59E3365FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Fix interaction between profiler hooks and finalizers. 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 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Sergey, I've checked the patch into all long-term branches in tarantool/luajit and bumped a new version in master, 2.10 and 1.10. On 06.06.22, Sergey Kaplun wrote: > From: Mike Pall > > Thanks to Julien Desgats. > > (cherry picked from commit 92fa45f9eb5d9aa732c6b972a85c26120d7612b4) > > Embedded LuaJIT profiler uses the following approach: > * Create trigger on timer signals, which set `HOOK_PROFILE` flag on > `g->hookmask` (if not set already) and update all BC instructions > dispatch. > * When any of instruction is executed, callback set by user on profiler > initialize is called. After the dispatch table updated again to > the old static values, and flags are reset. > * `HOOK_PROFILE` flag will set again and dispatch will updated at the next > tick of the timer. > > Before call to __gc finalizer the old hookmask is saved to be restored > later. When the second step is happening on call of __gc metamethod > `HOOK_PROFILE` flag is reset. But right after that the old hook > disposition (with `HOOK_PROFILE`) is restored, when we leaving > `gc_call_finalizer()` without updating the dispatch table, so the > profiler callback is never called again. > > This patch updates dispatch table right after hooks manipulation in > `gc_call_finalizer()` and prevent ticks influence inside finalizer > calls. > > Sergey Kaplun: > * added the description and the test for the problem > > Part of tarantool/tarantool#6548 > --- > > Side note: PR has 2 extra commits because the tarantool/luajit master > (tarantool branch) isn't bumped in the tarantool yet. > > Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-512-profiler-hook-finalizers-full-ci > Tarantool PR: https://github.com/tarantool/tarantool/pull/7237 > Related issues: > * https://github.com/LuaJIT/LuaJIT/issues/512 > * https://github.com/tarantool/tarantool/issues/6548 > > > src/lj_gc.c | 2 ++ > src/lj_obj.h | 3 +- > src/lj_profile.c | 2 +- > .../lj-512-profiler-hook-finalizers.test.lua | 31 +++++++++++++++++++ > 4 files changed, 36 insertions(+), 2 deletions(-) > create mode 100644 test/tarantool-tests/lj-512-profiler-hook-finalizers.test.lua > > -- > 2.34.1 > -- Best regards, IM