perf(termux): speed up non-tui cli startup (salvage #29438)#30121
Merged
Conversation
…erprint The bundled-skill sync stamp added in the cherry-picked salvage commit parsed .git/HEAD and looked for a loose ref file in the worktree gitdir only, so two real cases hit the unresolved branch: - repos after `git gc` where active refs live in packed-refs - linked worktrees, whose branch ref lives in <commondir>/refs/heads/ (verified on the worktree this salvage was built in) Both fell back to a constant-string fingerprint, so post-commit launches would never re-run the real skill sync. Now we resolve packed-refs and check both the worktree gitdir and the common dir for loose refs. Adds three tests covering: packed-refs resolution, worktree common-dir packed lookup, worktree common-dir loose lookup, and the explicit 'unresolved' marker (still stable + version-fallback-safe).
Contributor
🔎 Lint report:
|
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.
Salvage of #29438 — Termux non-TUI cold-start optimizations from @adybag14-cyber, cherry-picked onto current main (was 58 commits behind) with an additional fix on top.
What this PR makes true
On Termux/Android,
hermes,hermes chat,hermes -z ..., andhermes versionskip the full subparser tree and use the lightweight top-level parser. Background update prefetch and full bundled-skill rehash are opt-in (off by default) on Termux. Non-Termux behavior is unchanged.Author-reported timings (Termux):
--version/versionchat(invalid args)sync_skills(quiet=True)--help(full parser)Commits
perf(termux): speed up non-tui cli startup— @adybag14-cyber's original commit (cherry-picked, authorship preserved):_try_termux_fast_cli_launch()parallel to the already-merged_try_termux_fast_tui_launch()(perf(termux): speed up tui cold start #29419)._prepare_agent_startup()extracted fromcmd_acp(pure refactor, both call sites updated)..termux_bundled_sync_stampunderget_hermes_home()/skills/).HERMES_TERMUX_DISABLE_FAST_CLI=1,HERMES_TERMUX_PREFETCH_UPDATES=1,HERMES_TERMUX_FORCE_SKILLS_SYNC=1.fix(termux): resolve packed-refs and worktree refs in skill-sync fingerprint— follow-up on top:_read_git_revision_fingerprint()only checked loose refs in the worktree gitdir. Two real cases hit the unresolved branch and produced a constant-string fingerprint (skill sync would never re-run):git gcwhere active refs live inpacked-refs.<commondir>/refs/heads/(reproduced on the worktree this salvage was built in — fingerprint wasrefs/heads/<branch>:unresolvedbefore,refs/heads/<branch>:<sha>after).commondir, check both gitdir and common dir for loose refs, parsepacked-refs, and label genuinely-unresolvable refs explicitly (:unresolved— still stable, and__version__invalidates afterhermes update).Validation
tests/hermes_cli/test_tui_resume_flow.pytests/hermes_cli/test_startup_plugin_gating.py+test_subparser_routing_fallback.py+test_ignore_user_config_flags.py_read_git_revision_fingerprint()against this worktreegit:refs/heads/<branch>:<sha>(was:unresolvedbefore fix)git:refs/heads/main:<sha>tests/hermes_cli/test_tui_npm_install.py::test_make_tui_argv_skips_build_only_on_termux_when_fresh--expose-gcargv assertion), unrelatedCloses #29438.
Infographic