Repository navigation
Forward tl heap and nth_element to the standard library - #2475
Closed
nikosavola wants to merge 2 commits into
Closed
nikosavola wants to merge 2 commits into
nikosavola wants to merge 2 commits into
Conversation
Collaborator
|
why? I don't recall the exact reason I introduced that, but I think it was some MSVC STL implementation. It did not employ std::swap, so optimized overloads where not considered. Matthias |
- `tl::nth_element` and the heap functions forward to the standard library, the copied `nth_element` had no introselect fallback - `tl::sort` and `tl::partial_sort` stay because their tie order is observable, but the copied insertion sort helpers move instead of assign | case | before ms | after ms | speedup | |---|---:|---:|---:| | std_sort_boxes/100000 | 9.78 | 10.9 | 0.90x | | std_sort_boxes/1000000 | 112 | 122 | 0.92x | | std_sort_ints/100000 | 5.67 | 5.26 | 1.08x | | std_sort_ints/1000000 | 67.9 | 64.2 | 1.06x | | tl_nth_element_dups/100000 | 0.524 | 0.535 | 0.98x | | tl_nth_element_dups/1000000 | 7.37 | 7.28 | 1.01x | | tl_sort_boxes/100000 | 9.57 | 10.1 | 0.95x | | tl_sort_boxes/1000000 | 106 | 112 | 0.95x | | tl_sort_ints/100000 | 5.73 | 5.22 | 1.10x | | tl_sort_ints/1000000 | 67.8 | 61.9 | 1.10x | Measured on Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz, g++ -O2 (qmake default), median of 7 repetitions, before and after builds interleaved.
nikosavola
force-pushed
the
pr-tl-algorithm
branch
from
October 13, 2026 20:25
6626ee7 to
19a23a5
Compare
Contributor
Author
|
Thanks, that makes sense. tl::sort still uses its own partition with tl_iter_swap. I did not change that part. The parts I replaced did not use swap before either. The heap code just copied values. The standard nth_element uses iter_swap, and since C++11 that finds custom swap functions. Also, tl::nth_element is only used by tlKDTree, and that is only used in a test. So this is mostly cleanup. If you think it is not worth it, I can close it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tl::nth_elementand the heap functions forward to the standard library, the copiednth_elementhad no introselect fallbacktl::sortandtl::partial_sortstay because their tie order is observable, but the copied insertion sort helpers move instead of assignMeasured on Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz, g++ -O2 (qmake default), median of 7 repetitions, before and after builds interleaved.