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

Improve the build performance of mp_find. #99

Closed
wants to merge 2 commits into from

Conversation

Mizuchi
Copy link

@Mizuchi Mizuchi commented Oct 25, 2024

This improves the build time by looking up 100 elements in a batch.

Note this is just an optimization. It won't change any observable behavior. In addition, this is disabled for GCC due to a gcc bug.

Tested by creating a list with 996 elements and call mp_find: https://gist.github.com/Mizuchi/fce64eaa400288de136be1181f0edc96

The mp_find_2.cpp build time reduced from 400ms to 80ms.

It's possible to re-implement this with boost.preprocessor to make the batch size (100) configurable, but that will introduce boost.preprocessor as a dependency.

@Mizuchi Mizuchi force-pushed the develop branch 3 times, most recently from bd494b5 to f6f86e3 Compare October 25, 2024 09:03
@pdimov
Copy link
Member

pdimov commented Oct 25, 2024

I don't think that's going to work if the list contains duplicates.

@Mizuchi
Copy link
Author

Mizuchi commented Oct 25, 2024

I don't think that's going to work if the list contains duplicates.

Good point. It's fixable by (ab)using partial specialization order (I created a new commit for demo).

This can still reduce the build-time from 400ms to 140ms (for the mp_find_2.cpp example), though that makes the implementation much more complex.

Let me think about whether there is a better way to do. I'll close this pull request for now.

@Mizuchi Mizuchi closed this Oct 25, 2024
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.

2 participants