Reduce startup time for gambit --help and gambit --version#590
Open
anderkve wants to merge 3 commits into
Open
Reduce startup time for gambit --help and gambit --version#590anderkve wants to merge 3 commits into
gambit --help and gambit --version#590anderkve wants to merge 3 commits into
Conversation
…nary loads. By letting the gambit_preload library identify trivial gambit invocations like "gambit --help" and "gambit --version" and produce the correct CLI help text, we avoid having to wait for the full GAMBIT initialisation for these simple cases. (The GAMBIT initialisation typically takes a few seconds.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 PR uses two shortcuts to reduce the GAMBIT startup time for the trivial GAMBIT invocations
gambit --help,gambit --versionand simplygambitwith no arguments. In all these cases we just want to print some message to the terminal and exit, so there is no need to wait for the full GAMBIT initialisation.The first shortcut is in
core.cpp, where we get in before thecheck_databasesstep. On testing this saved ~1 second (~25% of the GAMBIT init time on those tests).The second shortcut lives in the preload library and is for now Linux-only (it uses
/proc/self/cmdline). Here the preload library directly identifies the trivial gambit invocations and outputs the correct terminal output (version number or CLI help text) and exits directly, without ever initialising the main gambit executable. So with this shortcut there is ~no startup time at all. For non-Linux systems, we just continue to the main GAMBIT executable where the first shortcut still saves us a bit of time.To avoid duplicating the CLI help text in the code, it has been extracted to a header file
gambit/Core/cli_help_text.hpp.