Skip to content

Reduce startup time for gambit --help and gambit --version#590

Open
anderkve wants to merge 3 commits into
masterfrom
improve_startup_time
Open

Reduce startup time for gambit --help and gambit --version#590
anderkve wants to merge 3 commits into
masterfrom
improve_startup_time

Conversation

@anderkve
Copy link
Copy Markdown
Collaborator

@anderkve anderkve commented May 6, 2026

This PR uses two shortcuts to reduce the GAMBIT startup time for the trivial GAMBIT invocations gambit --help, gambit --version and simply gambit with 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 the check_databases step. 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.

anderkve added 3 commits May 5, 2026 20:26
…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.)
@anderkve anderkve requested a review from patscott May 6, 2026 14:34
@anderkve anderkve added the Core Core group task label May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Core Core group task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant