Repository navigation
refactor(opencode): lazy-load commands so --version skips full startup - #50219
Closed
Fluffy-Bunny-23 wants to merge 1 commit into
Closed
Fluffy-Bunny-23 wants to merge 1 commit into
Fluffy-Bunny-23 wants to merge 1 commit into
Conversation
Implemented With: T3 Code via muse-spark-1.3-contributor-free on opencode
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
Contributor
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
Contributor
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Author
|
I am sorry for the incorrectly formatted PR. I have fixed the formatting issues. |
3 of 6 tasks
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.
Issue for this PR
No linked issue.
opencode --versionprints a compile-time constant but loads the entire static command graph first, which stretches into seconds on a loaded box.Type of change
What does this PR do?
Command modules now load only when their command actually runs.
--versionand top-level--helpstart just yargs plus a few dependency-free helpers. The default TUI command keeps a synchronous builder because yargs needs it to render top-level help, and its runtime loads on dispatch like everything else. No command behaves differently than before.On my machine (8-core Fedora box, compiled binary built with
script/build.ts --single --skip-install --skip-embed-web-ui),opencode --versionx5:Full runs, before real: 1.74, 1.50, 1.47, 1.38, 1.30s. After real: 0.12, 0.13, 0.15, 0.12, 0.13s. User CPU beat wall clock on every before run, so this was CPU-bound startup, not disk.
For cold page cache I evicted the binary pages with posix_fadvise and ran each side twice: before real 2.09s and 1.90s, after real 0.15s and 0.13s. So the worst case improves from about two seconds to well inside the target.
How did you verify your code works?
bun typecheckis clean andoxlintexits 0 on the touched files. Tests pass: thread (11, including live-spawn dispatch tests), help snapshots (34) plus error and smoke tests, attach, attention.--help,run --help,mcp --help, and the unknown-flag error output are byte-identical before and after. I also launched the TUI once and ran oneruninvocation on the built binary, both fine.Screenshots / recordings
No UI change, so none.
Checklist
This PR was autonomously generated with T3 Code via muse-spark-1.3-contributor-free on opencode