-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
feat(lua): allow some viml functions to run in fast #18306
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
Conversation
ac888db to
2c3b9f2
Compare
| enumerates functions that were called at least once. | ||
|
|
||
| Note: The majority of functions cannot run in fast callbacks with some | ||
| undocumented exceptions which are allowed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once we get around to generating eval.txt, this will follow. #18311
|
@bfredl are you able to describe the conditions that determine whether a function can be allowed/disallowed from running in fast events? Is it just textlock? |
|
(doesn't have to be in this PR) but I was wondering if it made sense to create a new table on I'm not sure if it's a good idea or if it exposes too much confusion, but the reason I suggest that is because then Haven't thought this through a ton yet though, so I could be completely wrong about the idea. |
We need to be a lot less willing to add random modules. Let's try to make |
|
I'm saying, the error can be confusing for users because it sometimes errors. I'm totally fine w/ us not adding another module, I just wanted to at least surface the issue and at least make sure we had considered it (since I didn't see it mentioned) |
|
To begin with One thing I like about |
|
I suspect calling these are being pretty niche, and not something most lua plugins are going to need consider (you can write many a nice lua plugin without going into the fast event loop at all, or |
|
Sounds good to me :) |
I think we can get that, and treesitter-based checks, and auto-completion, by annotation/flags. Even if that just means our docstring API: #12040 |
|
Anything else required here? |
src/nvim/lua/executor.c
Outdated
| return 1; | ||
| } | ||
|
|
||
| static bool viml_func_is_deferred_safe(const char_u *name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name is confusing because it returns fast but that's the opposite of "deferred".
Let's avoid needless entropy by using the same jargon everywhere by default (i.e. unless there's a clear reason to diverge). Consistent with nlua_in_fast_event, I would suggest a name like viml_func_is_fast.
src/nvim/lua/executor.c
Outdated
| size_t name_len; | ||
| const char_u *name = (const char_u *)luaL_checklstring(lstate, 1, &name_len); | ||
| if (!nlua_is_deferred_safe()) { | ||
| if (!nlua_is_deferred_safe() && !viml_func_is_deferred_safe(name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nlua_is_deferred_safe returns false if not in a fast context.
I think maybe nlua_is_deferred_safe should be modified to check find_internal_func().fast, we don't need a new function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally did this, but @bfredl suggested I separated it. Since nlua_is_deferred_safe is used in a ton of places in the API functions I think I agree it should be split. This new condition is only relevant to nvim_call.
This change adds the necessary plumbing to annotate functions in funcs.c as being allowed in run in luv fast events.
justinmk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgmt if (1) confirm that the test correctly fails, (2) @bfredl signoff
thanks for getting this started!
Co-authored-by: Justin M. Keyes <[email protected]>
Can confirm test fails locally if |
|
lgtm as before :) but still would like @bfredl signoff. Maybe mark a few more functions as |
|
I want to hold off adding more functions until I understand what properties a function must have for it to be safe to run in fast. Referencing an earlier comment:
@bfredl any advice before I start randomly adding functions to the list? |
|
I'd rather starting at the end at solving some problem (from either built-in or plugin Lua code), like iconv did. |
|
My main motivation here is to reduce the risk of Github issues that simply just involve I would rather we just mark all the functions we can to mitigate the potential of these issues. If a function really needs to run on the main event, then fine, but otherwise (so far) this has felt like death by a thousand paper cuts. |
This change adds the necessary plumbing to annotate functions in funcs.c
as being allowed in run in luv fast events.