Re: New portion of improvements for Dual-Pivot Quicksort

2010-07-06 Thread Tom Rodriguez
I actually looked into this in some detail and the reason for the difference in C1 is two fold. First the state of the JVM at array load is slightly different for a[i++] vs. a[i], i++. In the first case the top state has a copy of the original i but the local for i has i+1. In the second ther

Re: New portion of improvements for Dual-Pivot Quicksort

2010-07-06 Thread Osvaldo Doederlein
The ironic thing is that these operators were originally introduced in the C language, at least according to well-known folklore, as an optimization - taking advantage of inc/dec instructions from the PDP arch, in the old times when (I suppose) compilers wouldn't do even basic strength-reduction op

Re: New portion of improvements for Dual-Pivot Quicksort

2010-07-06 Thread David Holmes
I asked someone to take a look at this and it seems that the problem is that a[less++] requires introduction of a temporary to store the pre-incremented index value which in turn increases register pressure and can lead to a register spill. This seems to not only be architecture dependent but e

Re: New portion of improvements for Dual-Pivot Quicksort

2010-06-22 Thread Vladimir Iaroslavski
both computers with Intel processor: Pentium, Intel, 4 CPU, 3.2 GHz, 2 Gb RAM Pentium, Intel, 4 CPU, 2.8 GHz, 2 Gb RAM Osvaldo Pinali Doederlein wrote: Hi Vladimir, Hello, I tried with the latest JDK, build 98 and see different behaviour on two computers: 7570 / 8318 and 8560 / 8590, but so

Re: New portion of improvements for Dual-Pivot Quicksort

2010-06-22 Thread Osvaldo Pinali Doederlein
Hi Vladimir, Hello, I tried with the latest JDK, build 98 and see different behaviour on two computers: 7570 / 8318 and 8560 / 8590, but sorting method works slower with a[less++] instruction on both computers: Is the first computer (with larger performance diff) an AMD by any chance? It's

RE: New portion of improvements for Dual-Pivot Quicksort

2010-06-09 Thread Dmytro Sheyko
00 > From: iaroslav...@mail.ru > Subject: Re: New portion of improvements for Dual-Pivot Quicksort > To: dmytro_she...@hotmail.com > CC: core-libs-dev@openjdk.java.net > > Hello, > > Good catch! I agree with k!=p condition, but have doubt about using > Float.isNaN

Re: New portion of improvements for Dual-Pivot Quicksort

2010-06-02 Thread Vladimir Iaroslavski
Jun 2010 15:40:19 +0400 > From: iaroslav...@mail.ru > Subject: Re: New portion of improvements for Dual-Pivot Quicksort > To: dmytro_she...@hotmail.com > CC: joshua.bl...@google.com; core-libs-dev@openjdk.java.net > > Hi Dmytro, > > Very interesting investigation, thank you

Re: New portion of improvements for Dual-Pivot Quicksort

2010-06-01 Thread Vladimir Iaroslavski
120=40%)(48/120=40%)(36/120=30%)(24/120=20%)[376/1080=34%] Regards, Dmytro Sheyko > Date: Wed, 26 May 2010 16:12:17 +0400 > From: iaroslav...@mail.ru > Subject: Re: New portion of improvements for Dual-Pivot Quicksort > To: dmytro_she...@hotmail.com; joshua.bl...@google.com > C

Re: New portion of improvements for Dual-Pivot Quicksort

2010-05-31 Thread Vladimir Iaroslavski
; > Dmytro Sheyko wrote: > > That's great! Thank you. > > > > > Date: Fri, 21 May 2010 18:38:51 +0400 > > > From: iaroslav...@mail.ru > > > Subject: Re: New portion of improvements for Dual-Pivot Quicksort > > > To: dmytro_she.

Re: New portion of improvements for Dual-Pivot Quicksort

2010-05-27 Thread Rémi Forax
Le 20/05/2010 13:25, Dmytro Sheyko a écrit : Hi Remi, I believe that it is up to javac to generate compact and interpretation-efficient bytecode. No, javac is dumb, at least, when it translates instructions. And JITs love that. But anyway the first case seems to as acceptable as the second

Re: New portion of improvements for Dual-Pivot Quicksort

2010-05-26 Thread Vladimir Iaroslavski
jdk6: 9132 > > Dmytro Sheyko wrote: > > That's great! Thank you. > > > > > Date: Fri, 21 May 2010 18:38:51 +0400 > > > From: iaroslav...@mail.ru > > > Subject: Re: New portion of improvements for Dual-Pivot Quicksort > > > To: dmytro_she.

Re: New portion of improvements for Dual-Pivot Quicksort

2010-05-20 Thread Vladimir Iaroslavski
Sheyko > Date: Wed, 19 May 2010 14:41:32 +0400 > From: iaroslav...@mail.ru > Subject: Re: New portion of improvements for Dual-Pivot Quicksort > To: dmytro_she...@hotmail.com > CC: core-libs-dev@openjdk.java.net > > resend the class with correct constructor

RE: New portion of improvements for Dual-Pivot Quicksort

2010-05-20 Thread Dmytro Sheyko
0 12:09:57 +0200 From: fo...@univ-mlv.fr To: core-libs-dev@openjdk.java.net Subject: Re: New portion of improvements for Dual-Pivot Quicksort Le 19/05/2010 11:02, Dmytro Sheyko a écrit : Vladimir, I can see that you changed sortNegZeroAndNaN(float[]...) but probably forgot

Re: New portion of improvements for Dual-Pivot Quicksort

2010-05-19 Thread Rémi Forax
Le 19/05/2010 11:02, Dmytro Sheyko a écrit : Vladimir, I can see that you changed sortNegZeroAndNaN(float[]...) but probably forgot to change sortNegZeroAndNaN(double[]...). You really puzzled me with failed testcase and note that sorting algorithm (without special attention to zeros) genera

RE: New portion of improvements for Dual-Pivot Quicksort

2010-05-19 Thread Dmytro Sheyko
} I prefer the second one. Thanks a lot, Dmytro Sheyko > Date: Tue, 18 May 2010 18:57:50 +0400 > From: iaroslav...@mail.ru > Subject: Re: New portion of improvements for Dual-Pivot Quicksort > To: dmytro_she...@hotmail.com > CC: core-libs-dev@openjdk.java.net > >

Re: New portion of improvements for Dual-Pivot Quicksort

2010-05-17 Thread Vladimir Iaroslavski
Hello, Thank you for review, I'll check and run tests again with you changes. Thank you, Vladimir Dmytro Sheyko wrote: Hello, More ideas. 1. We can use Double.doubleToRawLongBits instead of Double.doubleToLongBits and Float.floatToRawIntBits instead of Float.floatToIntBits. No need to handle

Re: New portion of improvements for Dual-Pivot Quicksort

2010-05-12 Thread Vladimir Iaroslavski
Hello Dmytro, Thank you for reviewing float/double section! I'll look at your code and run tests tomorrow and let you know results. Best regards, Vladimir Dmytro Sheyko wrote: Vladimir, Your changes are good for me. Additionally I have some comments/proposals regarding dealing with negative

Re: New portion of improvements for Dual-Pivot Quicksort

2010-05-12 Thread Vladimir Iaroslavski
Hello Dmytro, Could you please send new version of DPQ with your changes? Thanks, Vladimir Dmytro Sheyko wrote: Vladimir, Your changes are good for me. Additionally I have some comments/proposals regarding dealing with negative zeros. 1. Scanning for the first zero we can avoid range chec

Re: New portion of improvements for Dual-Pivot Quicksort

2010-05-07 Thread Vladimir Iaroslavski
Hi Dmytro, Your suggested variant is better than variant with fromIndex. It works little bit faster than my original one: ~0.7% for client and the same for server VM (my variant with boolean flag uses opposite value, and it works slower than yours). Now the ratio of times is: new / jdk7: 0.88 f

Re: New portion of improvements for Dual-Pivot Quicksort

2010-05-07 Thread Vladimir Iaroslavski
Hello Dmytro, I tried this case too, and the results are the same. But to be sure, I will check your version again. Thank you, Vladimir Dmytro Sheyko wrote: Hi, Wouldn't it better to use boolean flag instead of int index? -- Dmytro Sheyko PS --- DualPivotQuicksortWithoutSentinel.javaFr

Re: New portion of improvements for Dual-Pivot Quicksort

2010-05-06 Thread Vladimir Iaroslavski
mail.ru > Subject: Re: New portion of improvements for Dual-Pivot Quicksort > To: dmytro_she...@hotmail.com > CC: core-libs-dev@openjdk.java.net > > Hi Dmytro, > > Thank you very much for suggestions! I checked it and here > is my results: > > If we consider

RE: New portion of improvements for Dual-Pivot Quicksort

2010-05-06 Thread Dmytro Sheyko
ed, 5 May 2010 21:23:37 +0400 > From: iaroslav...@mail.ru > Subject: Re: New portion of improvements for Dual-Pivot Quicksort > To: dmytro_she...@hotmail.com > CC: core-libs-dev@openjdk.java.net > > Hi Dmytro, > > Thank you very much for suggestions! I checked it and here >

RE: New portion of improvements for Dual-Pivot Quicksort

2010-05-06 Thread Dmytro Sheyko
, Dmytro Sheyko > Date: Fri, 30 Apr 2010 17:11:10 +0400 > Subject: Re: New portion of improvements for Dual-Pivot Quicksort > From: vladimir.iaroslav...@googlemail.com > To: dmytro_she...@hotmail.com > CC: core-libs-dev@openjdk.java.net > > Hello Dmytro, > > Please, see

Re: New portion of improvements for Dual-Pivot Quicksort

2010-05-05 Thread Joshua Bloch
Vladimir, On Wed, May 5, 2010 at 12:57 AM, Joshua Bloch wrote: > > The sentinel technique that you use in lines 118 - 136 is questionable: you > are modifying a portion of the array outside the specified range of the > call, which arguably violates the contract of the call, and could be > observ

Re: New portion of improvements for Dual-Pivot Quicksort

2010-05-05 Thread Vladimir Iaroslavski
Hi Dmytro, Thank you very much for suggestions! I checked it and here is my results: If we consider case when the whole array is sorted, we can omit setting sentinel and restoring original value: // int before = a[left - 1]; a[left - 1] = Integer.MIN_VALUE; for (int j, i = left + 1; i <=

Re: New portion of improvements for Dual-Pivot Quicksort

2010-05-05 Thread Vladimir Iaroslavski
Josh, Thank you very much for review. I'll prepare updated version and send it with my comments soon. Vladimir Joshua Bloch wrote: Vladimir, Hi. I'm thrilled that you were able to eke so much more perforance out of this already optimized code. I read your changes on my flight to Pittsburgh.

RE: New portion of improvements for Dual-Pivot Quicksort

2010-05-05 Thread Dmytro Sheyko
Hi Vladimir, The trick with sentinel is quite cute. Going farther, I think it is not always necessary to replace left outer element with the least possible value (and restore it later after sorting) because after partitioning every element in adjoining array part can play the role of sentinel.

Re: New portion of improvements for Dual-Pivot Quicksort

2010-05-04 Thread Joshua Bloch
Vladimir, Hi. I'm thrilled that you were able to eke so much more perforance out of this already optimized code. I read your changes on my flight to Pittsburgh. Here's the code review: I think the comment on lines 102-105 was too useful to delete: 102... This 103 * method differs

Re: New portion of improvements for Dual-Pivot Quicksort

2010-04-30 Thread Vladimir Iaroslavski
Hello Dmytro, Please, see file test/java/util/Arrays/Sorting.java in the JDK repository, It contains unit tests. Thank you, Vladimir 2010/4/30 Dmytro Sheyko : > Hello Vladimir, > > Could you remind me where can I find sources for the test suite? > > Thanks, > Dmytro > >> Date: Tue, 27 Apr 2010 0

RE: New portion of improvements for Dual-Pivot Quicksort

2010-04-30 Thread Dmytro Sheyko
Hello Vladimir, Could you remind me where can I find sources for the test suite? Thanks, Dmytro > Date: Tue, 27 Apr 2010 01:50:08 +0400 > Subject: New portion of improvements for Dual-Pivot Quicksort > From: vladimir.iaroslav...@googlemail.com > To: core-libs-dev@openjdk.java.net > > Hello, ev

Re: New portion of improvements for Dual-Pivot Quicksort

2010-04-29 Thread Goktug Gokdogan
One quick comment: you can consider moving trivial array check so it will be executed only if insertion sort threshold check passes: if (length < INSERTION_SORT_THRESHOLD) { if (length < 2) { return; } On Mon, Apr 26, 2010 at 2:50 PM, Vladimir Iaroslavski < vladimir.iaroslav...@g

Re: New portion of improvements for Dual-Pivot Quicksort

2010-04-28 Thread Joshua Bloch
Vladimir, Cool! I will look at the changes tomorrow (Wednesday). Have you told Jon Bentely? Josh On Mon, Apr 26, 2010 at 2:50 PM, Vladimir Iaroslavski < vladimir.iaroslav...@googlemail.com> wrote: > Hello, everyone! > > I've investigated the implementation of the Dual-Pivot Quicksort > wh