Skip to content
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

Merged
merged 25 commits into from
Apr 4, 2024
Merged

speed up syft unit tests #8572

merged 25 commits into from
Apr 4, 2024

Conversation

abyesilyurt
Copy link
Contributor

@abyesilyurt abyesilyurt commented Mar 13, 2024

Description

I did some profiling on the unit tests and cleared up some bottlenecks.

There is roughly 35% speed up.

Local:

  • before: 2 min.
  • after: 1 min.

CI:

  • before: 6 min.
  • after: 4 min.

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?

  • unit tess

Checklist

@abyesilyurt abyesilyurt changed the title Aziz/unittests speed up syft unit tests Mar 13, 2024
@abyesilyurt abyesilyurt marked this pull request as ready for review March 14, 2024 10:28
@@ -106,6 +108,7 @@ def salt_and_hash_password(password: str, rounds: int) -> tuple[str, str]:
return salt_bytes, hashed_bytes


@cache
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved caching to conftest

Comment on lines 212 to 216
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)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@abyesilyurt abyesilyurt self-assigned this Mar 18, 2024
Copy link
Contributor

@eelcovdw eelcovdw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@abyesilyurt abyesilyurt merged commit ed8293a into dev Apr 4, 2024
35 checks passed
@abyesilyurt abyesilyurt deleted the aziz/unittests branch April 4, 2024 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants