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

investigate performance #44

Open
jku opened this issue Jul 10, 2024 · 3 comments
Open

investigate performance #44

jku opened this issue Jul 10, 2024 · 3 comments

Comments

@jku
Copy link
Member

jku commented Jul 10, 2024

The test suite feels a little slow: there should be no need for an individual test to take a perceptible amount of time

My guess is that the pytest integration has lead to infrastructure setup happening for each test: We should really only need one web server (SimulatorServer) as it gives each RepositorySimulator a subdirectory and should be able to serve all of them.

@jku
Copy link
Member Author

jku commented Jul 12, 2024

see also #17

@jku
Copy link
Member Author

jku commented Jul 12, 2024

Only the python-tuf tests seem slow so this is unlikely to be related to the http server startup/shutdown.

@jku
Copy link
Member Author

jku commented Aug 15, 2024

Quick look at cProfile results implies the issue is Python startup (basically module import) for clients/python-tuf: we're starting a new python executable several hundred times (since each init, refresh and download_target is a new execution) which is not optimal for an interpreted language. Each startup seems to take something like 0.1 seconds on my laptop.

Potential improvements:

  • keep the client running and give the commands over IPC: this seems very complicated and would be another client API
  • parallelize test runs: the infra should be roughly designed correctly for that. pytest-xdist makes the test run ~50% faster based on a quick try
  • shave unnecessary repetition from tests
    • e.g. test_multiple_changes_to_target() invokes the client 43 times. I think shaving 80% of those would be easy and would not reduce coverage: the test could do all of the metadata changes it now does but only invoke client a few times instead of constantly (test_file_download.py: Don't make > 40 client calls in a test #165)
    • a common pattern is refresh+download_target. The refresh is not strictly necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant