-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
WIP: copy config function source into the compiled file #192
base: master
Are you sure you want to change the base?
Conversation
@wbthomason does this mean that the compiled output would actually contain the functions themselves from users config e.g. the |
@akinsho: Just the |
Well it's probably not a major point but not sure what the tradeoffs are, the duplication I think is unlikely to be particularly meaningful to most people andI think the ability to actually be able to inspect that file would be a huge win for readability 😄 . When I was working on the compile related reloading, trying to figure out what was happening meant looking for changes amongst the gibberish in the |
True, legibility would be a benefit. |
On a separate but vaguely related note, I spent a bit of time looking into the upvalue stuff using debug info and getting values from scopes I wonder if you've run into anything about that. This link shows some of the debug functions. One of the ones that was particularly interesting was |
The reason I don't use |
@kevinhwang91 do you have any links to benchmarks or posts describing the slowness of |
maybe just profiling the execution/startup time with this PR vs. the default behaviour would be enough to figure out if loadstring is slower. |
My own ad hoc benchmarks of the two were inconclusive. Additionally, while @kevinhwang91, if you have examples showing that |
I'm so sorry for my preconceived bias, I learn lua from https://www.lua.org/pil/8.html which said:
I simply run the original function is: setup = function()
local i = 0
i = i + 1
i = i + 1
i = i + 1
i = i + 1
i = i + 1
i = i + 1
i = i + 1
i = i + 1
i = i + 1
i = i + 1
i = i + 1
i = i + 1
end so |
Just something I was playing around with - by adapting the functions given in the answer here: https://stackoverflow.com/questions/29871102/in-trepl-or-luajit-how-can-i-find-the-source-code-of-a-library-im-using/29872347#29872347 we can extract the source of a user's config (or eventually setup, etc.) functions and put them directly in the compiled output, rather than using
loadstring
.This is kinda cool, but it's not clear that it's helpful - on the one hand, functions created with
loadstring
are never JIT'd, but on the other hand, these functions should only run once and are unlikely to benefit from JITing. This approach also creates code duplication by copying the function source to the compiled file.I'm mostly just posting this draft PR in case others see it and can think of a reason that it's worth pursuing further. This PR is 90% working, but I need to fix the output of the
packer_plugins
table to capture a reference to the config functions rather than just the string of their names.