-
Notifications
You must be signed in to change notification settings - Fork 576
deprecate and remove qsort? #13234
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
Comments
From @nwc10tl;dr: Nothing current uses C<use sort 'quicksort';> - should we remove it? The sort pragma was added by this commit in 5.7.x times: commit 84d4ea4 Implement the sort pragma. Split sort code from pp_ctl.c p4raw-id: //depot/perl@13179 Part of the reason, I think, was that v5.6 and earlier's sort was a By the time v5.8.0 shipped, the only options offered were 'stable', qw(_qsort) gets you a quicksort, qw(_qsort stable) gets you a quicksort with Of the 28 distributions that mention C<use sort>, most are in documentation: http://grep.cpan.me/?q=%5Cbuse%5Cs%2Bsort.*%28stable%7Cqsort%7Cquicksort%7Cmergesort%7Csafe%7Cfast%29 All the code is C<use sort 'stable'> with 3 exceptions. 1) This commented-out code in a regression test: # uncomment to enable compatibility with perl versions prior to 5.8 2) 3 examples in Module-Pragma-0.02/example/sort.t 3) 2 uses in Class::Std::Containers, which fails tests with v5.10.0 and later So, 1) nothing will break if we removed _qsort. 2) sort.pm's documentation, from the start, has stated this: You can force the 3) We shave off some source code: embed.fnc | 3 +- [plus a bit in lib/sort.pm, which I didn't touch for this prototype] 4) We reduce the size of pp_sort.o by about 3K (or about 0.25% of perl) but it's not exactly high maintenence code. So, should we put _qsort through a deprecation cycle, and drop it in v5.23? I'm not actually sure if it's worth it. Do the small gains outweigh the small Nicholas Clark |
From @shlomifHi Nicholas and all, On Fri, 06 Sep 2013 05:42:18 -0700
I'm OK with either way. I never used the "use sort" pragma. Regards, Shlomi Fish -- Shlomi Fish http://www.shlomifish.org/ <petn-randall> Writing your own nirvana may be easier than writing a good Please reply to list if it's a mailing list post - http://shlom.in/reply . |
The RT System itself - Status changed from 'new' to 'open' |
From @tseeOn 09/06/2013 02:42 PM, Nicholas Clark (via RT) wrote:
... on CPAN.
It's certainly not, nut pp_sort.c as a whole is moderately complex.
+1 to see it go. I'm trying not to grandly suggest that somebody (not --Steffen |
From @jplinderman
Stability was definitely a feature, but my best argument to Jarkko was that The only sequences (that I could think of, anyway) where it was clear that My email address in pp_sort.c is shown as jpl@research.att.com. That will I have no strong opinion about removing qsort. Seems like a good idea to |
From victor@vsespb.ru2013/9/6 John P. Linderman <jpl.jpl@gmail.com>
Seems memory usage can be better with qsort than with mergesort (not sure http://en.wikipedia.org/wiki/Merge_sortMerge sort's most common implementation does not sort in place; therefore,
|
From @jplindermanAll true, all valid observations. The merge sort implementation uses N On Fri, Sep 6, 2013 at 3:34 PM, Victor Efimov <victor@vsespb.ru> wrote:
|
From @ap* John P. Linderman <jpl.jpl@gmail.com> [2013-09-07 00:35]:
Computer’s Perspective on Moore’s Law: -- |
From victor@vsespb.ruI was able to reproduce case when qsort do 3 times less comparison than However I was unable to find case when qsort faster when comparsion == my @a = (1..3) x 100_000; sub mysub my ($q, $m); print $q/$m, "\n";
|
From @jplindermanOn Fri, 06 Sep 2013 18:54:12, Steffen Mueller <smueller@cpan.org> wrote:
I hope it's clear who copied whom. If not, read on. Anything indented following a "> " is text extracted from http://svn.python.org/projects/python/trunk/Objects/listsort.txt Tim Peters' description of "timsort". Let's clear the air right away.
In http://svn.python.org/projects/python/trunk/Objects/listobject.c,
Seems that Tim was aware of the sort code Jarkko and I were kicking about. http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-09/msg00027.html Anyway, we have, at the very start
<wink> doesn't cut the mustard. He borrowed some of the best parts Since "Peter" can too easily be confused with "Peters", I'll refer to I'm unaware of any algorithms whose performance is "supernatural". http://code.google.com/p/timsort/source/browse/trunk/timSort.c?spec=svn17&r=17 (which I believe to have a few bugs, but is at least comprehensible So let's start with some simple combinatorics, and let's assume that 1,2 and in which case we either have a strictly increasing sequence or a Add another (distinct) value, 3, to our two original values and we have 1,2,3 started increasing, continued to be In random (distinct) data, there's only 1 chance in 3 that looking for 1,2,3,4 started increasing, continued to be Now there's only 2 chances in 8 that the comparison will extend the
But, of course, if you want to detect runs longer than 2, you must Peter's sort addressed both of these problems. (The run setup I won't go into much detail about the merge phase, which is really the
When using element w of one run as a "wedge" into the other run, cmp(w,b) <= sense This technique is one of a very few contributions I made as Peter My other contribution, done without Peter watching over my shoulder I don't pretend to know how much balanced run lengths contribute to Here's a more accurate citation for Peter's sort, prior to our working "Optimistic Sorting and Information Theoretic Complexity" |
From @jplindermanOn Fri, 06 Sep 2013 18:54:12, Steffen Mueller <smueller@cpan.org> wrote:
My recent attempt to copy and paste a commentary on timsort appears to have Executive summary: I see no reason to believe that our sort, based on code |
From @jplinderman |
From @nwc10On Fri, Sep 06, 2013 at 02:59:44PM -0400, John P. Linderman wrote:
On Mon, Sep 09, 2013 at 10:55:33AM -0400, John P. Linderman wrote:
So this is an appropriate change to make to pp_sort.c? Inline Patchdiff --git a/pp_sort.c b/pp_sort.c
index b65e9eb..ab4a6fd 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -53,9 +53,15 @@
* The original code was written in conjunction with BSD Computer Software
* Research Group at University of California, Berkeley.
*
- * See also: "Optimistic Merge Sort" (SODA '92)
+ * See also: "Optimistic Sorting and Information Theoretic Complexity"
+ * Peter McIlroy
+ * SODA (Fourth Annual ACM-SIAM Symposium on Discrete Algorithms),
+ * pp 467-474, Austin, Texas, 25-27 January 1993.
*
- * The integration to Perl is by John P. Linderman <jpl@research.att.com>.
+ * The integration to Perl is by John P. Linderman <jpl.jpl@gmail.com>.
+ *
+ * John described some more details of the implementation here:
+ * http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2013-09/msg00345.html
*
* The code can be distributed under the same terms as Perl itself.
*
Nicholas Clark |
From @nwc10On Fri, Sep 06, 2013 at 06:54:12PM +0200, Steffen Mueller wrote:
Good point. Nothing on CPAN will break, and probably nothing else.
That seems to be the principal benefit. Nicholas Clark |
From @nwc10On Fri, Sep 06, 2013 at 02:59:44PM -0400, John P. Linderman wrote:
The bit that keeps bugging me is "how many people know that their data is In that, the amount of use cases where it's correct to specify qsort instead In which case, seems that choosing a specific sort algorithm is not the Nicholas Clark |
From @jplindermanIf you don't mind, I'd prefer to leave off that final reference to my On Thu, Sep 12, 2013 at 8:41 AM, Nicholas Clark <nick@ccl4.org> wrote:
|
From @nwc10On Thu, Sep 12, 2013 at 09:58:28AM -0400, John P. Linderman wrote:
I just culled both lines. If a wikipedia page appears, we can update [And then the wikipedia talk folks can debate whether it's notable, and Nicholas Clark |
From @cpansproutOn Thu Sep 12 05:54:17 2013, nicholas wrote:
But would it be possible for perl to detect datasets that work better -- Father Chrysostomos |
From @jplindermanI'm actually in complete agreement. I just wanted to acknowledge that A line in Peter's SODA paper has always intrigued me Versus the fastest readily available qsort, [a citation here to Jon Qsort is constrained to elements of fixed size, and the elements themselves But now I wonder if there may not have been another contributing cause. The original merge sort, in use since 5.7, was as fast as, or faster than, then the ability to ignore stability will take away that advantage of On Thu, Sep 12, 2013 at 8:53 AM, Nicholas Clark <nick@ccl4.org> wrote:
|
From zefram@fysh.orgDiscussion on this petered out, having mostly got sidetracked into If no one objects, I intend to go ahead with removal. -zefram |
From @jplindermanZefram wrote: Date: Mon, 13 Nov 2017 02:44:28 +0000 If no one objects, I intend to go ahead with removal. I've been among those proposing that qsort may be taking more code-space |
From @jplindermanA couple days ago, I sent a reply to Zefram's proposal to remove qsort. I |
From @xsawyerxOn Sun, 12 Nov 2017 18:44:44 -0800, zefram@fysh.org wrote:
Agreed. |
From zefram@fysh.orgDone in commit e2091bb. -zefram |
@xsawyerx - Status changed from 'open' to 'pending release' |
From @avarOn Thu, Nov 16 2017, Sawyer X. via jotted:
All in all I don't mind that this got removed like this, but I thought I.e.: 1. Obscure feature is discovered There's a big DarkPAN out there. E.g. Sawyer and I both work for a (Now, in that particular case I have no idea why _quicksort was used, I wonder if we should at least do this for now: diff --git a/lib/sort.pm b/lib/sort.pm Or maybe it really is better if this dies at compile-time. FWIW I initially ran into this because I was hacking some pod docs that commit 1bb8507c8f perlfunc: shorten overly verbose & out of date mention of sort.pm This paragraph saying a 5.8 feature "may persist" in future versions diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod -Perl 5.6 and earlier used a quicksort algorithm to implement sort. I.e. my reading of these docs was that the 5.8 reference was simply some |
From zefram@fysh.orgAvar Arnfjorth Bjarmason wrote:
There's no real need for that: the error that it'll produce leads one -zefram |
From @jplindermanI'll admit that I was a bit disappointed that my response to Zefram's I spoke with Jon Bentley last week. He confirmed my observation that if N It would be a shame to deny users the performance gains that qsort makes On Wed, Dec 6, 2017 at 9:23 AM, Ævar Arnfjörð Bjarmason <avarab@gmail.com>
|
From @jplindermanARRGH! My response again disappeared from the digest I just received. I.e. my reading of these docs was that the 5.8 reference was simply some ... [Message clipped] View entire message On Wed, Dec 6, 2017 at 10:37 AM, John P. Linderman <jpl.jpl@gmail.com>
|
From @xsawyerxOn 12/06/2017 04:51 PM, Zefram wrote:
Is this a price too high to pay for deprecating this over time? In other words, why avoid deprecating this cleanly as we usually do? |
From zefram@fysh.orgSawyer X wrote:
Because it's never been a fully supported feature. It has never incurred -zefram |
From @xsawyerxOn 12/18/2017 01:18 PM, Zefram wrote:
Good reason. |
From @jplinderman>
Long term, the _qsort subpragma surely deserves to die. It asks the users ... benchmarks indicated that for some inputs, on some platforms, the I'm now convinced that this had much less to do with platform than with ...the ability to characterize the input or output in implementation https://algs4.cs.princeton.edu/references/papers/bentley-mcilroy.pdf with its sophisticated selection of pivot elements, will do an even better |
From @khwilliamsonThank you for filing this report. You have helped make Perl better. With the release yesterday of Perl 5.28.0, this and 185 other issues have been Perl 5.28.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#119635 (status was 'resolved')
Searchable as RT119635$
The text was updated successfully, but these errors were encountered: