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

TimSort #12

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open

Conversation

zamazan4ik
Copy link

This is initial version of TimSort. Can you do review, please?

Copy link
Collaborator

@spreadsort spreadsort left a comment

Choose a reason for hiding this comment

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

The source looks ok.

What's the Jamfile change about?

We'll need tests, a benchmark, (can be simple), and a mini-review of the code before we can submit this. It'll also be necessary to add this to the documentation (in quickbooks) but that should be fairly simple with just one library call.

My thought is that once you have the tests + benchmark, we can run a mini-review, but should wait on merging it in until the parallel library has finished merging.

@zamazan4ik
Copy link
Author

zamazan4ik commented Dec 27, 2016

Ok. I will add tests, benchmarks, etc. in a few days.

Added range support for spreadsort, integer_sort, float_sort, string_sort.
which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n
\par
Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>,
so @c integer_sort is asymptotically faster
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for catching the integer_sort references, but you missed one here.

Fixed doxygen, rewrited stable_test for timsort, renamed some variables.
Copy link
Collaborator

@spreadsort spreadsort left a comment

Choose a reason for hiding this comment

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

I get compile errors when I grab this. Does this use C++11, and if so, is it really necessary? Not everyone has a C++11 compiler yet (I can build C++11, but deliberately use the default b2 for testing).

gcc.compile.c++ ../../bin.v2/libs/sort/test/timsort.test/gcc-5.4.0/debug/timsort_test.o
In file included from test/timsort_test.cpp:9:0:
../../boost/sort/timsort.hpp:45:7: error: using template type parameter ‘Compare’ after ‘class’
class Compare
^
../../boost/sort/timsort.hpp:97:13: error: ‘Compare’ is not a template
typedef Compare<const value_t &, Compare> compare_t;
^
../../boost/sort/timsort.hpp: In static member function ‘static void boost::sort::TimSort<RandomAccessIterator, Compare>::binarySort(boo
st::sort::TimSort<RandomAccessIterator, Compare>::iter_t, boost::sort::TimSort<RandomAccessIterator, Compare>::iter_t, boost::sort::TimS
ort<RandomAccessIterator, Compare>::iter_t, boost::sort::TimSort<RandomAccessIterator, Compare>::compare_t)’:
../../boost/sort/timsort.hpp:170:39: error: ‘move’ is not a member of ‘std’
/const/ value_t pivot = std::move(*start);
^
../../boost/sort/timsort.hpp:175:22: error: ‘move’ is not a member of ‘std’
p = std::move((p - 1));

Replaced std::move and std::move_backward by boost::move and boost::move_backward.
@zamazan4ik
Copy link
Author

zamazan4ik commented Jan 12, 2017

Thank you for catching this. My bad, sorry for this stupid mistake.

Currently we can compile timsort.hpp with -std=c++03 and -std=c++98.

Copy link
Collaborator

@spreadsort spreadsort left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes.

The mostly-sorted benchmark numbers were really impressive! It's 10+X faster than even pdqsort in that case. It's slower in the random input case, as is expected.

It'd be interesting to write a chunk-aware spreadsort based on what timsort takes advantage of, but I don't have the time.

Let me know when you're ready for a mini-review, and a 10-day time period when you can answer all questions about timsort promptly, and I'll try to get this on the review schedule. Note: I will expect you to maintain the timsort portion of the library and be responsive to email after the library is submitted.

@zamazan4ik
Copy link
Author

zamazan4ik commented Jan 13, 2017

Ok. Thank you for your help.

Currently i have a lot of work, so i think will be great, if we will start review in 2-3 weeks (e.g. on 10 February). I will be ready to answer all questions about TimSort. What do you think about this idea?

All can talk with me by GitHub (most oreferred way), e-mail ([email protected]), or IRC #boost (nickname: zamazan4ik, zamazan4ik_). My timezone: UTC +3 (Belarus, Minsk).

@spreadsort
Copy link
Collaborator

I'm still in discussions with Francisco, who wrote the comparison-based half of the Boost.Sort library that he's in the process of integrating into the whole. He is the logical person to run the mini-review if he has the time. Once that's sorted out we'll figure out when is best for a mini review and whether he requires more changes first.

@zamazan4ik
Copy link
Author

Ok. Important information: on 1-12 February i will be at hospital, so i haven't good possibilities to participate in mini-review. After 12 February i will be ready.

@zamazan4ik
Copy link
Author

zamazan4ik commented Mar 13, 2017

Hello. What is the status of the review?

@spreadsort
Copy link
Collaborator

spreadsort commented Mar 14, 2017 via email

@zamazan4ik
Copy link
Author

Thank you a lot :)

@spreadsort
Copy link
Collaborator

I added your range wrapper code changes to develop (including the attribution you added and the documentation error corrections), as those aren't controversial. I still haven't heard back from Francisco, and if he doesn't get back I'll run the review myself.

@zamazan4ik
Copy link
Author

Hello @spreadsort . What the review status?

@spreadsort
Copy link
Collaborator

The review is starting tomorrow. I've emailed you and the boost list about it. Please be responsive to questions.

@zamazan4ik
Copy link
Author

I collected some useful links for potential reviewers:

  1. Wiki
  2. brief description in python dev list
  3. Original implementation

@spreadsort
Copy link
Collaborator

Please answer the questions on the boost list directly.

@spreadsort
Copy link
Collaborator

My email is [email protected]. Please email me directly. If I'm to accept your source, I need to be able to contact you to discuss it and have the assurance that you'll fix bugs in it.

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