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

Stop creating new lua_State for each function call. At least for C functions. #5406

Open
Gerold103 opened this issue Oct 9, 2020 · 0 comments
Labels

Comments

@Gerold103
Copy link
Collaborator

Call of _func functions creates a new lua_State via luaT_newthread(), and moves all the arguments to it. This is slow, probably very slow, but nobody measured properly. Should be most visible on C functions.

The new lua_State is not really needed - all can be done on the provided lua_State. For example, lbox_func_call() has a lua_State with all its arguments in it. No need to move them to a new state.

Why it is not done now I think is because port_lua does not support dumping not the entire lua_State. See encode_lua_call(). On the other hand the first argument is often a callable object (box.func.<name>, for example), which can't be popped from the stack (may trigger its GC). So an offset 1 would solve the problem.

The same will happen for the upcoming cbox module for calling C functions without touching the schema.

@kyukhin kyukhin added feature A new functionality lua labels Jul 13, 2021
@kyukhin kyukhin added this to the wishlist milestone Jul 13, 2021
@igormunkin igormunkin removed this from the wishlist milestone Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants