Repository navigation
perf(cli): load command code only after argument parsing - #947
Merged
Merged
Conversation
The CLI entry imported the dispatch, error-projection, compute-log and observability layers before parsing arguments, which pulled in compiler, planner, adapter and output models plus pydantic-settings. `sqb --version` and every `--help` paid about 0.7 s of CPU for roughly 930 modules. Parsing now loads only the parser and its type modules; the dispatch layers load after a command is parsed. The dispatch path itself no longer imports heavy models for annotations: the compile request models move beside the CLI entry models, the warehouse scope context moves out of the warehouse resolution module, provider and output annotations use lazy type aliases, and the provider base class, pydantic and rich load where they are used. Help text, parse errors, exit codes and JSON output are unchanged. A fresh-process test guards that version, help, parse errors and a plain compile do not load warehouse drivers, integrations, pydantic-settings or rich, and that parsing alone loads no compiler or pydantic modules.
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.
Why
Every
sqbinvocation imported about 930 modules before parsing arguments, sosqb --versionand every--helptook ~0.8 s of CPU, and every command paid that before doing any work. Stage 2 of CHI-482 (CHI-499); it also lets the planned no-change compile fast path answer before loading the compiler.Changes
--version/--help.Verification
--versionand--help0.77 → 0.12 s; startup before the compile handler ~0.75 → ~0.35–0.45 s; warm compile unchanged.--jsoncases.make test,make check-ci.