perf(termux): speed up non-tui cli startup#29438
Closed
adybag14-cyber wants to merge 1 commit into
Closed
Conversation
Contributor
|
Salvaged onto current main via #30121 (rebase-merge → 2a474bc — your authorship preserved in git log). Cherry-picked your commit and added a follow-up that resolves packed-refs and worktree common-dir loose refs, so the skill-sync stamp invalidates correctly on repos after |
19 tasks
1 task
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.
What does this PR do?
Optimizes non-TUI Hermes CLI cold starts on Termux/Android for older single-core mobile devices, while keeping the desktop startup path unchanged.
The previous Termux TUI cold-start work is now upstream. This follow-up targets classic CLI/script invocations:
hermeshermes chat ...hermes -z ...hermes --versionhermes versionOn Termux, obvious non-TUI chat/oneshot/version invocations now use the lightweight top-level/chat parser and skip building the full subcommand tree.
--helpstill falls back to the full parser so complete help output is preserved.For debugging or exact legacy behavior, set
HERMES_TERMUX_DISABLE_FAST_CLI=1.This also removes two expensive chat-start side effects from the default Termux path:
HERMES_TERMUX_PREFETCH_UPDATES=1HERMES_TERMUX_FORCE_SKILLS_SYNC=1forces the old full sync pathThe bundled-skill cache remains update-safe: after a git/update revision changes, the next launch runs a real sync and refreshes the stamp.
Local Termux timing with this branch loaded through the installed Hermes venv:
python -m hermes_cli.main --version: median0.357sbefore ->0.222safterpython -m hermes_cli.main version: median0.362sbefore ->0.219safterpython -m hermes_cli.main chat --bogus: median0.300sbefore ->0.215saftertools.skills_sync.sync_skills(quiet=True): median0.075sbefore -> cached Termux skip0.0001safterpython -m hermes_cli.main --help: remains on the full parser, median about0.32sRelated Issue
N/A
Type of Change
Changes Made
hermes_cli/main.pyHERMES_TERMUX_DISABLE_FAST_CLI=1as an escape hatch for the new parser shortcut._prepare_agent_startup()so the full parser and fast parser share the same agent lifecycle setup.HERMES_TERMUX_PREFETCH_UPDATES=1.HERMES_TERMUX_FORCE_SKILLS_SYNC=1.tests/hermes_cli/test_tui_resume_flow.pyHow to Test
/data/data/com.termux/files/home/.hermes/hermes-agent/.venv/bin/python -m pytest -o addopts='' tests/hermes_cli/test_tui_resume_flow.py::test_termux_fast_cli_launch_chat_uses_light_parser tests/hermes_cli/test_tui_resume_flow.py::test_termux_fast_cli_launch_oneshot_uses_light_parser tests/hermes_cli/test_tui_resume_flow.py::test_termux_fast_cli_launch_version_skips_update_check tests/hermes_cli/test_tui_resume_flow.py::test_termux_fast_cli_launch_skips_help tests/hermes_cli/test_tui_resume_flow.py::test_termux_fast_cli_launch_can_be_disabled tests/hermes_cli/test_tui_resume_flow.py::test_termux_bundled_skills_stamp_controls_sync tests/hermes_cli/test_tui_resume_flow.py::test_termux_skips_bundled_skill_sync_when_stamp_fresh tests/hermes_cli/test_tui_resume_flow.py::test_termux_forced_bundled_skill_sync_runs -qChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
N/A
Screenshots / Logs
Focused test output:
Timing output: