-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CT-97] [Bug] dbt cli with an empty command takes more than a second to run #4627
Comments
Haven't worked with flamegraphs before so took me some time to understand this one. I think a good amount of the runtime is importing the classes from https://github.com/dbt-labs/dbt-core/blob/v1.0.1/core/dbt/main.py#L18-L33 Since the defaults are only used if a subcommand is being called, was thinking we could improve performance by only importing the relevant
If that sounds like a good approach, I'd be happy to create an example PR. As with any performance optimizations, I'm sure there will be tradeoffs to my approach so no worries if the code is never merged. Curious to learn more about dbt's internals. :) |
Thanks for the detailed analysis @ajmarcus! Anecdotally, I definitely notice this myself when I call Because of this, I'm going to close this ticket but explicitly mention it in the other tickets as additional context for why this work is important. Thanks so much for providing all the details here. |
Sounds great and makes sense! |
Is there an existing issue for this?
Current Behavior
When I run the
dbt
command in my terminal without additional arguments, it takes more than a second to print the help text:Looks like this is a related issue with percieved run performance for specific commands:
#4625
Expected Behavior
Basic operations with the
dbt
cli would take less than one second to run.Steps To Reproduce
Install dbt:
Run dbt:
Relevant log output
This could deflinitely be an issue with my machine or setup. To see if I could find more information I used
py-spy
to generate a flamegraph using these commands:There is nothing conclusive, but looks like there is a lot of time spent with calls to
importlib
:https://gist.githubusercontent.com/ajmarcus/b077f4c8a94582df74c39258325addf5/raw/9af82bb55f5b322fb10bc0a959c20b175e689c3c/profile_cli_empty.svg
Which reminded me that Python eagerly loads imported dependencies.
importlib
does provide a lazy import loader but it comes with this warning:https://python.readthedocs.io/en/latest/library/importlib.html#importlib.util.LazyLoader
Environment
What database are you using dbt with?
bigquery
Additional Context
The text was updated successfully, but these errors were encountered: