Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feat: luajit replace lua #697

Merged
merged 22 commits into from
Jul 20, 2022
Merged

✨ feat: luajit replace lua #697

merged 22 commits into from
Jul 20, 2022

Conversation

xiaobiaozhao
Copy link
Contributor

  1. Luajit replace lua
  2. rm test case "cmsgpack can pack and unpack circular references". Becase luajit's core code diffrent from lua. Also, different compilers produce different code execution effects (GCC&clang on Ubuntu).

@PragmaTwice
Copy link
Member

PragmaTwice commented Jun 29, 2022

Thanks for your hard work.

rm test case "cmsgpack can pack and unpack circular references". Becase luajit's core code diffrent from lua. Also, different compilers produce different code execution effects (GCC&clang on Ubuntu).

I did not get this point, could you elaborate on it?

I think that the JIT mechanism should not affect the original semantics, and the same interpreter / JIT program should keep same behavior while compiled by different C compilers. So we should consider it as a serious problem if it really has some difference on semantics between the original interpreter and the JIT, or between different C compilers.

And I think the same problem as #609 (#614) for luajit needs to be solved.

@@ -263,9 +263,10 @@ start_server {tags {"scripting"}} {
assert(re.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x)
-- so, the final x.x is at the depth limit and was assigned nil
assert(re.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x == nil)
return {h, re.x.x.x.x.x.x.x.x.y == re.y, re.y == 5}
assert(h == "82a17881a17882a17881a17882a17881a17882a17881a17882a17881a17882a17881a17882a17881a17882a17881a178c0a17905a17905a17905a17905a17905a17905a17905a17905" or h == "82a17905a17881a17882a17905a17881a17882a17905a17881a17882a17905a17881a17882a17905a17881a17882a17905a17881a17882a17905a17881a17882a17905a17881a178c0")
Copy link
Member

@PragmaTwice PragmaTwice Jun 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why there are two different values of h?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got it. It is due to the element order of a table is unstable. This reminds me of Map in golang.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, It behaves differently in different compilers

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, It behaves differently in different compilers

I still have deep doubts about this, because I think we should try to avoid semantics behaving differently under different compilers.

Copy link
Member

@PragmaTwice PragmaTwice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I commented in discussion, Redis did some changes to lua codebases, not only lua extensions. You can check here to see these commits. I haven't investigated carefully what all these changes affect, and this may need some work.

Other comments are inline.

CMakeLists.txt Show resolved Hide resolved
cmake/luajit.cmake Outdated Show resolved Hide resolved
cmake/luajit.cmake Outdated Show resolved Hide resolved
cmake/luajit.cmake Outdated Show resolved Hide resolved
src/scripting.h Outdated Show resolved Hide resolved
@xiaobiaozhao
Copy link
Contributor Author

BTW, We can do the Luajit extension based on this repository. https://github.com/openresty/luajit2.
The repo add some new function https://github.com/openresty/luajit2#new-lua-apis

@git-hulk git-hulk requested review from ShooterIT and tisonkun July 1, 2022 06:37
@PragmaTwice
Copy link
Member

PragmaTwice commented Jul 2, 2022

In order to use sanitizers, you not only need to add compile options, but also link options. (which may be why CI is currently failing)
Also, don't forget to remove these sanitizer options when the bug is fixed : )

@xiaobiaozhao
Copy link
Contributor Author

image
This is mem leak on my ubuntu

@git-hulk
Copy link
Member

git-hulk commented Jul 3, 2022

Many thanks for @xiaobiaozhao hard try

@xiaobiaozhao
Copy link
Contributor Author

xiaobiaozhao commented Jul 6, 2022

As I commented in discussion, Redis did some changes to lua codebases, not only lua extensions. You can check here to see these commits. I haven't investigated carefully what all these changes affect, and this may need some work.

Other comments are inline.

here The part of the lua code is modified for Redis 7.0, mainly the "redis function". I don't think this part needs to be ported to KVROCKS at this time

@PragmaTwice
Copy link
Member

PragmaTwice commented Jul 6, 2022

here The part of the lua code is modified for Redis 7.0, mainly the "redis function". I don't think this part needs to be ported to KVROCKS at this time

Thanks for your investigation.

How do you think about this idea: #697 (comment) ?
I think it is not a hard job to support both since all these APIs are same.

If users encounter incompatibility between luajit and lua that makes the previous code unable to execute properly, or other problems with luajit, they can choose to switch to original lua to avoid it.

@git-hulk
Copy link
Member

git-hulk commented Jul 6, 2022

@tisonkun and @ShooterIT can take a look if you have time. For #697 (comment), I also prefer providing an option to let user fallback if they have any problem.

General implementation is good to me.

CMakeLists.txt Outdated Show resolved Hide resolved
src/server.h Outdated Show resolved Hide resolved
@PragmaTwice
Copy link
Member

Maybe you need to add *.hpp to line 42 in lua.cmake to pass the "Ubuntu GCC without luajit" job.

@xiaobiaozhao
Copy link
Contributor Author

Maybe you need to add *.hpp to line 42 in lua.cmake to pass the "Ubuntu GCC without luajit" job.

done

git-hulk
git-hulk previously approved these changes Jul 12, 2022
tisonkun
tisonkun previously approved these changes Jul 13, 2022
git-hulk
git-hulk previously approved these changes Jul 13, 2022
@PragmaTwice
Copy link
Member

There are some memory leaks reported by ASan which are steadily reproduced and need some investigation.

The rest is good for me. 👍

@git-hulk
Copy link
Member

There are some memory leaks reported by ASan which are steadily reproduced and need some investigation.

The rest is good for me. 👍

Those memory leaks looks not related to this PR.

@PragmaTwice
Copy link
Member

PragmaTwice commented Jul 14, 2022

Those memory leaks looks not related to this PR.

Seems these reported leaks are steadily (100%) reproduced for more than 10 times, and do not appear in other PRs and the unstable branch, so I think it is hard to say that it is not related to this PR.

I'll take a deeper look when I have time : )

@git-hulk
Copy link
Member

git-hulk commented Jul 19, 2022

Those memory leaks looks not related to this PR.

Seems these reported leaks are steadily (100%) reproduced for more than 10 times, and do not appear in other PRs and the unstable branch, so I think it is hard to say that it is not related to this PR.

I'll take a deeper look when I have time : )

I fixed those issues in #714 and it looks good now, I think this PR would be also became green after #714.

@PragmaTwice PragmaTwice dismissed stale reviews from git-hulk and tisonkun via ba54b75 July 20, 2022 08:38
@git-hulk
Copy link
Member

@tisonkun @PragmaTwice @ShooterIT I think we can merge this PR if no objections.

Copy link
Member

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you very much for this fruitful contribution @xiaobiaozhao!

@git-hulk one thing to point out is that we may not include this change in 2.1.0 release and at earliest in 2.2.0.

Copy link
Member

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you very much for this fruitful contribution @xiaobiaozhao!

@git-hulk one thing to point out is that we may not include this change in 2.1.0 release and at earliest in 2.2.0.

Copy link
Member

@PragmaTwice PragmaTwice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for such a great work.

@git-hulk
Copy link
Member

@tisonkun Agree, I also think this is a big change and we can release it on the next release.

@git-hulk
Copy link
Member

Thanks all, merging...

@git-hulk git-hulk merged commit bacb45a into apache:unstable Jul 20, 2022
@git-hulk
Copy link
Member

Thanks for @xiaobiaozhao great contribution again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants