-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
speed up syft unit tests #8572
speed up syft unit tests #8572
Conversation
@@ -106,6 +108,7 @@ def salt_and_hash_password(password: str, rounds: int) -> tuple[str, str]: | |||
return salt_bytes, hashed_bytes | |||
|
|||
|
|||
@cache |
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.
Is the caching only to speed up CI? Not sure we want to do the caching with real passwords
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.
moved caching to conftest
packages/syft/tests/conftest.py
Outdated
SyftClientSessionCache._get_key = ( | ||
lambda email, password, connection: f"{email}{password}{connection}" | ||
) | ||
user.salt_and_hash_password = cache(user.salt_and_hash_password) | ||
user.check_pwd = cache(user.check_pwd) |
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 should be provisioned through monkeypatch.setattr
in the fixture instead of making it a global patch?
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.
Good point! I applied the changes.
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.
Looks good!
Description
I did some profiling on the unit tests and cleared up some bottlenecks.
There is roughly 35% speed up.
Local:
CI:
Affected Dependencies
Added orjson library for faster json processing.Hashing relies on the json file formatting and orjson is missing white spacing which is not configurable. So this change was reverted although there still some potential gains to be made.How has this been tested?
Checklist