Skip to content

Make Labels selection not O(n^2) #320

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
Jul 30, 2024
Merged

Make Labels selection not O(n^2) #320

merged 1 commit into from
Jul 30, 2024

Conversation

Luthaf
Copy link
Member

@Luthaf Luthaf commented Jul 29, 2024

Instead we can exploit the underlying HashMap structure of Labels.

Fixes #319, bringing the calculation down to 2.5s on my machine. There might be more optimizations to do here, but at least the worst issue is gone.

╔════╦══════════════════════════════════════════════╦════════════╦═══════════╦══════════╦══════════╗
║ id ║ span name                                    ║ call count ║ called by ║ total    ║ mean     ║
╠════╬══════════════════════════════════════════════╬════════════╬═══════════╬══════════╬══════════╣
║  1 ║ Calculator::prepare                          ║          1 ║         — ║    1.65s ║    1.65s ║
╠════╬══════════════════════════════════════════════╬════════════╬═══════════╬══════════╬══════════╣
║  0 ║ NeighborsList                                ║          1 ║         1 ║ 375.89ms ║ 375.89ms ║
╠════╬══════════════════════════════════════════════╬════════════╬═══════════╬══════════╬══════════╣
║  2 ║ NeighborList::compute                        ║          1 ║         — ║ 786.14ms ║ 786.14ms ║
╚════╩══════════════════════════════════════════════╩════════════╩═══════════╩══════════╩══════════╝


📚 Documentation preview 📚: https://rascaline--320.org.readthedocs.build/en/320/

Instead we can exploit the underlying HashMap structure of
Labels
Copy link

Here is a pre-built version of the code in this pull request: wheels.zip, you can install it locally by unzipping wheels.zip and using pip to install the file matching your system

Copy link
Contributor

@PicoCentauri PicoCentauri left a comment

Choose a reason for hiding this comment

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

One inner loop is gone which is good enough.

@Luthaf Luthaf merged commit 9ea277d into master Jul 30, 2024
26 checks passed
@Luthaf Luthaf deleted the faster-selection branch July 30, 2024 14:37
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.

Sample selection is extremely slow for NeighborList
2 participants