Tarantool development patches archive
 help / color / mirror / Atom feed
From: Igor Munkin via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Kaplun <skaplun@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH luajit] Fix interaction between profiler hooks and finalizers.
Date: Thu, 30 Jun 2022 15:10:24 +0300	[thread overview]
Message-ID: <Yr2SsOJzMUdql5y3@tarantool.org> (raw)
In-Reply-To: <20220606133528.13355-1-skaplun@tarantool.org>

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 <mike>
> 
> 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
> 

<snipped>

> -- 
> 2.34.1
> 

-- 
Best regards,
IM

      parent reply	other threads:[~2022-06-30 12:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-06 13:35 Sergey Kaplun via Tarantool-patches
2022-06-27 16:22 ` sergos via Tarantool-patches
2022-06-29  8:07 ` Igor Munkin via Tarantool-patches
2022-06-30 12:10 ` Igor Munkin via Tarantool-patches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yr2SsOJzMUdql5y3@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imun@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit] Fix interaction between profiler hooks and finalizers.' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox