Try initializing namespaces lazily #258
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is something of a proof of concept, as it doesn't seem to speed up official Joker much that I can measure on the two machines I'm using while on vacation (and my main development machine, at home, is even less likely to show much of a difference).
But, applied to my
gostd
fork, the resulting Joker definitely starts up faster, though still not as quickly as official Joker. (I think there's room for further improvement, in terms of delayingvar
-time initialization untilInit()
is called. That might help things further.)That suggests this PR, or something like it, could keep Joker startup times from getting much longer even if/as more namespaces and/or functions (vars) are added to its default library.
Note that, while trying different ideas out, I was disappointed to discover that Go currently does not offer much in the way of practical build-time initialization, beyond scalar constants. That is, arrays and maps, in particular, cannot be initialized at build time and thus be present, already-initialized, when the resulting executable starts up. I hope to see improvements in this situation someday soon, and might look into how feasible it is to do and possibly offer to help with them.