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

perf: Improve performance of test_util_vcs.py #654

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AnsahMohammad
Copy link
Contributor

Working out a solution to improve the performance of test_util_vcs.py

This PR fixes #67

@AnsahMohammad
Copy link
Contributor Author

This is the execution time for each test-case :

Time            test-case
============================================================================== slowest durations ==============================================================================
4.40s call     test/test_util_vcs.py::test_workdir_outgoing[hg]
3.50s call     test/test_util_vcs.py::test_get_changed_files_two_revisions[hg]
2.22s call     test/test_util_vcs.py::test_working_directory_clean[hg]
2.12s call     test/test_util_vcs.py::test_find_latest_common_revision[hg]
1.59s call     test/test_util_vcs.py::test_update[hg]
1.49s call     test/test_util_vcs.py::test_get_changed_files_one_added_file[hg]
1.37s call     test/test_util_vcs.py::test_get_changed_files_one_deleted_file[hg]
1.37s call     test/test_util_vcs.py::test_does_revision_exist_locally[hg]
1.31s call     test/test_util_vcs.py::test_get_changed_files_one_modified_file[hg]
1.17s call     test/test_util_vcs.py::test_branch[hg]
0.76s call     test/test_util_vcs.py::test_get_changed_files_no_changes[hg]
0.59s call     test/test_util_vcs.py::test_get_commit_message[hg-commit message in\u2026 pure utf8]
0.58s setup    test/test_util_vcs.py::test_workdir_outgoing[hg]
0.58s call     test/test_util_vcs.py::test_get_commit_message[hg-commit message in... ascii]
0.54s setup    test/test_util_vcs.py::test_get_repository[git]
0.54s call     test/test_util_vcs.py::test_all_remote_names[hg]
0.38s call     test/test_util_vcs.py::test_get_repo_path[hg]
0.33s call     test/test_util_vcs.py::test_remote_name_many_remotes[hg]
0.32s call     test/test_util_vcs.py::test_remote_name_default_and_origin[hg]
0.21s setup    test/test_util_vcs.py::test_find_latest_common_revision[hg]
0.21s setup    test/test_util_vcs.py::test_remote_name_many_remotes[hg]
0.20s call     test/test_util_vcs.py::test_calculate_head_rev[hg]
0.19s setup    test/test_util_vcs.py::test_default_branch_remote_query[hg]
0.19s setup    test/test_util_vcs.py::test_remote_name_default_and_origin[hg]
0.18s call     test/test_util_vcs.py::test_remote_name_no_remote[hg]
0.18s setup    test/test_util_vcs.py::test_all_remote_names[hg]
0.18s setup    test/test_util_vcs.py::test_remote_name[hg]
0.16s call     test/test_util_vcs.py::test_remote_name[hg]
0.07s call     test/test_util_vcs.py::test_workdir_outgoing[git]
0.04s call     test/test_util_vcs.py::test_get_changed_files_two_revisions[git]
0.03s call     test/test_util_vcs.py::test_find_latest_common_revision[git]
0.03s call     test/test_util_vcs.py::test_working_directory_clean[git]
0.03s call     test/test_util_vcs.py::test_get_changed_files_one_modified_file[git]
0.03s call     test/test_util_vcs.py::test_remote_name_many_remotes[git]
0.03s setup    test/test_util_vcs.py::test_workdir_outgoing[git]
0.03s call     test/test_util_vcs.py::test_branch[git]
0.03s call     test/test_util_vcs.py::test_remote_name_default_and_origin[git]
0.03s setup    test/test_util_vcs.py::test_all_remote_names[git]
0.02s setup    test/test_util_vcs.py::test_default_branch_remote_query[git]
0.02s call     test/test_util_vcs.py::test_update[git]
0.02s setup    test/test_util_vcs.py::test_find_latest_common_revision[git]
0.02s call     test/test_util_vcs.py::test_get_commit_message[git-commit message in\u2026 pure utf8]
0.02s call     test/test_util_vcs.py::test_get_changed_files_one_added_file[git]
0.02s setup    test/test_util_vcs.py::test_remote_name_many_remotes[git]
0.02s setup    test/test_util_vcs.py::test_remote_name[git]
0.02s setup    test/test_util_vcs.py::test_remote_name_default_and_origin[git]
0.02s call     test/test_util_vcs.py::test_get_commit_message[git-commit message in... ascii]
0.02s call     test/test_util_vcs.py::test_all_remote_names[git]
0.02s call     test/test_util_vcs.py::test_get_changed_files_one_deleted_file[git]
0.02s call     test/test_util_vcs.py::test_does_revision_exist_locally[git]
0.01s call     test/test_util_vcs.py::test_default_branch_cloned_metadata[git]
0.01s call     test/test_util_vcs.py::test_default_branch_remote_query[git]
0.01s setup    test/test_util_vcs.py::test_get_commit_message[git-commit message in... ascii]
0.01s call     test/test_util_vcs.py::test_get_changed_files_no_changes[git]
0.01s call     test/test_util_vcs.py::test_remote_name[git]
0.01s call     test/test_util_vcs.py::test_default_branch_guess[git]
0.01s setup    test/test_util_vcs.py::test_get_commit_message[git-commit message in\u2026 pure utf8]
0.01s call     test/test_util_vcs.py::test_get_repo_path[git]

We can see that hg takes significantly more time than git for the same test cases.
Git completes all test cases in 1.82 seconds
Hg takes 26.77 seconds for the same execution

Findings :
Initially, I suspected that repo.run() was the primary bottleneck. However, after further analysis, get_outgoing_files() also contributes significantly to the slowdown.
To analyze the bottleneck, I broke down test_workdir_outgoing() into 8 segments (Reference code) :

These were the time taken for git and hg respectively:

Segment Hg (seconds) Git (seconds)
1 0.0001 0.0004
2 0.4328 0.0078
3 0.3877 0.0098
4 0.6698 0.0113
5 0.2441 0.0155
6 1.4716 0.0338
7 0.4483 0.0191
8 1.5036 0.0348

@AnsahMohammad
Copy link
Contributor Author

@ahal Any suggestions on the best way to tackle this issue?

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

Successfully merging this pull request may close these issues.

Improve performance of test_util_vcs.py
1 participant