[Tarantool-patches] [PATCH luajit] Emit sunk IR_NEWREF only once per key on snapshot replay.

Igor Munkin imun at tarantool.org
Thu Feb 15 16:41:43 MSK 2024


Sergey,

I've checked the patchset into all long-term branches in
tarantool/luajit and bumped a new version in master, release/3.0 and
release/2.11.

On 11.12.23, Sergey Kaplun via Tarantool-patches wrote:
> From: Mike Pall <mike>
> 
> Thanks to Sergey Kaplun and Peter Cawley.
> 
> (cherry-picked from commit 1761fd2ef79ffe1778011c7e9cb03ed361b48c5e)
> 
> Assume we have the parent trace with the following IRs:
> 
> | 0001 }  tab TNEW   #0    #0
> | 0002 }  p32 NEWREF 0001  "key"
> | 0003 }  fal HSTORE 0002  false
> | ....        SNAP   #1   [ ---- ---- 0001 ---- ]
> | 0004 >  num SLOAD  #1    T
> | ....        SNAP   #2   [ ---- ---- 0001 ]
> | 0005 >  num EQ     0004  0004
> | 0006 }  tru HSTORE 0002  true
> | ....        SNAP   #3   [ ---- ---- 0001 true ]
> 
> The side trace for the third snapshot emits the following IRs:
> 
> | 0001    tab TNEW   #0    #0
> | 0002    p32 NEWREF 0001  "key"
> | 0003    fal HSTORE 0002  false
> | 0004    p32 NEWREF 0001  "key"
> | 0005    tru HSTORE 0004  true
> 
> As we can see, `NEWREF` is emitted twice. This is a violation of its
> semantics, so the second store isn't noticeable.
> 
> This patch prevents the second emitting of IR NEWREF by checking the last
> one emitted NEWREF IR. There is no need to check NEWREFs beyond since
> it guarantees the snapshot is taken after it, because it may cause table
> rehashing, so all prior results are invalidated.
> 
> Sergey Kaplun:
> * added the description and the test for the problem
> 
> Resolves tarantool/tarantool#7937
> Part of tarantool/tarantool#9145
> ---
> 
> Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-1128-double-ir-newref-on-restore-sunk
> PR: https://github.com/tarantool/tarantool/pull/9466
> Related issues:
> * https://github.com/LuaJIT/LuaJIT/issues/1128
> * https://github.com/tarantool/tarantool/issues/7937
> 
>  src/lj_snap.c                                 | 16 ++++
>  ...-double-ir-newref-on-restore-sunk.test.lua | 81 +++++++++++++++++++
>  2 files changed, 97 insertions(+)
>  create mode 100644 test/tarantool-tests/lj-1128-double-ir-newref-on-restore-sunk.test.lua
> 

<snipped>

> -- 
> 2.43.0
> 

-- 
Best regards,
IM


More information about the Tarantool-patches mailing list