Which best practices for lua are applicable to neovim's luajit and should there be a resource for such recommendations? #24327
sandersantema
started this conversation in
General
Replies: 1 comment
-
Most performance recommendations for LuaJIT are specifically for numerical code, which is unlikely to be relevant to Neovim plugins (or config): So the basic recommendations are the same. In particular: always benchmark before you try to optimize. If something is not a bottleneck for your code, readability is (much!) more important than shaving a few percent off. (All the things you mention tend to be negligible compared to the actual workload you have to perform.) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There are some resources online about best practices in regards to lua performance, such as this lua gems chapter. But what isn't clear to me is whether this is applicable to luajit and specifically to luajit as it is running under neovim.
Some examples of these best practices for lua are
string.format
instead of string concatenation (..
)string.format
is more expensive than callingformat
when defined as a locallocal format = string.format
Looking through some plugins I see that these best practices are often not followed. I wanted to improve this and open a pr for one such plugin which is performance critical but I'm not at all certain whether these best practices hold for luajit, hence this discussion.
Furthermore taking a cursory look at the neovim itself (
rg '[^\.]\.\.[^\.]' --type lua -g '!*_spec.lua' -g '!*test*'
that is), it seems..
is used quite a lot too.To be clear: I'm not referring to best practices in regards to plugin development and such but rather to best practices for performance specific to luajit and neovim.
I think it would be a good idea if there were some general recommendations of best practices in regards to performance, which could hopefully be based on measurements and expertise and because of that hopefully not that controversial either.
Beta Was this translation helpful? Give feedback.
All reactions