[Tarantool-patches] [PATCH luajit] ffi/gc: restore back rehashing of finalizers table

Igor Munkin imun at tarantool.org
Fri Mar 21 16:17:53 MSK 2025


Sergey,

Thanks for the patch! For the history: as we discussed, the patch LGTM.

BTW, I'd rather prefer to split the revert and the fix into two separate
patches, but I haven't been here for so long since you're in charge ;)

On 20.03.25, Sergey Kaplun via Tarantool-patches wrote:
> This is a follow-up to the commits
> 2115828bc6fae911215cd07593df2ae0a83a0f42 ("FFI: Drop finalizer table
> rehash after GC cycle.") and bfcbaa70e7b3e720578c05db3f66d832419e8566
> ("Drop unused function wrapper."). After them, the rehashing of the cdata
> finalizer table at the end of the GC cycle is dropped. Without
> reshashing of this table, the table increases the estimated amount of
> memory for the GC. Hence, with the bigger `estimate`, the threshold
> before starting the GC cycle is increased too. This allows allocating
> more cdata objects and increasing the size of the finalizer table again.
> This increases the memory estimate again and so on. As a result, we have
> unlimited memory growth without rehashing of the table for the
> cdata-intensive workloads.
> 
> This patch reverts back the code changes (but not the test) of the
> aforementioned commits. Also, it fixes the possible crash after
> rehashing of the cdata finalizers table by adding the protected call to
> the GC steps on the trace itself and on the trace exit.
> ---
> 
> Branch: https://github.com/tarantool/luajit/tree/refs/heads/skaplun/gh-noticket-fix-gc-finalizer-pressure
> Related issue: https://github.com/LuaJIT/LuaJIT/issues/1350
> 
> See also:
> * https://github.com/LuaJIT/LuaJIT/issues/1247
> * https://github.com/LuaJIT/LuaJIT/pull/946
> 
>  src/lj_gc.c                                   | 31 +++++++++-
>  src/lj_obj.h                                  |  2 +-
>  src/lj_tab.c                                  |  7 +++
>  src/lj_tab.h                                  |  3 +
>  src/lj_trace.c                                | 20 +++++-
>  ...lj-1350-fix-gc-finalizer-pressure.test.lua | 61 +++++++++++++++++++
>  6 files changed, 119 insertions(+), 5 deletions(-)
>  create mode 100644 test/tarantool-tests/lj-1350-fix-gc-finalizer-pressure.test.lua
> 

<snipped>

> -- 
> 2.48.1
> 

-- 
Best regards,
IM


More information about the Tarantool-patches mailing list