Skip to content

cacheprovider: speed up NFPlugin when --nf is not enabled #7130

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

Merged
merged 1 commit into from
Apr 29, 2020

Conversation

bluetech
Copy link
Member

The code used an O(n^2) loop. Replace list with set to make it O(n).

For backward compatibility the filesystem cache still remains a list.

On this test:

import pytest
@pytest.mark.parametrize("x", range(5000))
def test_foo(x): pass

run with pytest --collect-only:

Before: 0m1.251s
After: 0m0.921s

@bluetech
Copy link
Member Author

Due to the O(n^2), as N grows the slowness becomes more pronounced, e.g. changing 5000 -> 50000, the difference becomes 9.5s vs. 35.5s.

cc @boxed -- thought I'd let you know about performance fixes, let me know if you don't want me to.

@bluetech bluetech force-pushed the cacheprovider-nf-set branch from 0441d2a to 3495a6e Compare April 28, 2020 20:12
@boxed
Copy link
Contributor

boxed commented Apr 29, 2020

Thanks for the notification. I absolutely want you to!

The code used an O(n^2) loop. Replace list with set to make it O(n).

For backward compatibility the filesystem cache still remains a list.

On this test:

    import pytest
    @pytest.mark.parametrize("x", range(5000))
    def test_foo(x): pass

run with `pytest --collect-only`:

Before: 0m1.251s
After:  0m0.921s
@bluetech bluetech force-pushed the cacheprovider-nf-set branch from 3495a6e to 4a42afd Compare April 29, 2020 10:02
Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

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

lovely restructure

@bluetech bluetech merged commit e5d6e58 into pytest-dev:master Apr 29, 2020
@bluetech bluetech deleted the cacheprovider-nf-set branch June 17, 2020 14:56
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.

3 participants