-
Notifications
You must be signed in to change notification settings - Fork 25
Enhance git credential helper performances #6372
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
Conversation
CodSpeed Performance ReportMerging #6372 will not alter performanceComparing Summary
|
@@ -51,7 +51,7 @@ def get( | |||
raise typer.Exit(1) from exc | |||
|
|||
client = InfrahubClientSync(config=Config(address=config.SETTINGS.main.internal_address, insert_tracker=True)) | |||
repo = client.get(kind=InfrahubKind.GENERICREPOSITORY, location__value=location) | |||
repo = client.get(kind=CoreGenericRepository.__name__, location__value=location) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This avoids importing above infrahub.core.constants, even if performance improvement is negligible. One comment on this is that all client sync methods expect dedicated sync protocols as input, but they are actually buggy as we deduce the kind from their class name (eg: CoreGenericRepositorySync
in an invalid kind). That is what I used __name__
above to avoid breaking typing while using the non-sync protocol CoreGenericRepository
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened a bug in the SDK for this: opsmill/infrahub-sdk-python#380
Not convinced if we should go with the above or just use the hardcoded string "CoreGenericRepository", for now, as we're sending in a string in the above example it doesn't actually provide any extra value. Aside from having some loose reference to a "constant".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from having some loose reference to a "constant"
Yes that is the idea, I feel it's still better than a hardcoded string even though it is not ideal..
dccd832
to
ee4bd26
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, perhaps we should spend a minute or two on this during the daily just to explain why we have this change.
From
time python helper.py: elapsed 1.31s
to
time python helper.py: elapsed 0.26s
The main improvement comes from the fact
git_credential.helper
importsinfrahub.config
, itself importinginfrahub.database.constants
which imports a lot of code asinfrahub.database.__init__
contains a lot of logic. This PR moves these database constants in a separatedinfrahub.constants
package that is fast to import. Note the long term fix would be to cleaninfrahub.database.__init__
in order to finally restore these constants withininfrahub.database
.