Bug 150828 - B3/Air should use bubble sort for their insertion sets, because it's faster than std::stable_sort
Summary: B3/Air should use bubble sort for their insertion sets, because it's faster t...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Filip Pizlo
URL:
Keywords:
Depends on:
Blocks: 150279
  Show dependency treegraph
 
Reported: 2015-11-02 17:36 PST by Filip Pizlo
Modified: 2015-11-03 12:27 PST (History)
3 users (show)

See Also:


Attachments
the patch (12.93 KB, patch)
2015-11-02 17:43 PST, Filip Pizlo
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2015-11-02 17:36:23 PST
std::stable_sort really sucks.  We should use bubble sort instead.
Comment 1 Filip Pizlo 2015-11-02 17:43:20 PST
Created attachment 264651 [details]
the patch
Comment 2 WebKit Commit Bot 2015-11-02 17:46:13 PST
Attachment 264651 [details] did not pass style-queue:


ERROR: Source/WTF/wtf/BubbleSort.h:42:  Should have only a single space after a punctuation in a comment.  [whitespace/comments] [5]
ERROR: Source/WTF/wtf/BubbleSort.h:44:  Should have only a single space after a punctuation in a comment.  [whitespace/comments] [5]
Total errors found: 2 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Alex Christensen 2015-11-02 20:41:15 PST
Comment on attachment 264651 [details]
the patch

Would it be as fast if you added something to eliminate the possibility of the worst case, such as when the number of swaps reaches 5 times the number of elements fall back to std::stable_sort? 5 is arbitrary
Comment 4 Geoffrey Garen 2015-11-02 21:19:25 PST
Comment on attachment 264651 [details]
the patch

Why not insertion sort? Equally easy, fewer writes because it doesn't swap.
Comment 5 Filip Pizlo 2015-11-03 10:41:32 PST
(In reply to comment #4)
> Comment on attachment 264651 [details]
> the patch
> 
> Why not insertion sort? Equally easy, fewer writes because it doesn't swap.

Style points!
Comment 6 Geoffrey Garen 2015-11-03 10:43:01 PST
:(
Comment 7 Filip Pizlo 2015-11-03 10:50:41 PST
(In reply to comment #6)
> :(

In all seriousness, I just wanted a quick fix to undo the perf regression caused by using std::stable_sort.

I filed a bug to fix this: https://bugs.webkit.org/show_bug.cgi?id=150843
Comment 8 Filip Pizlo 2015-11-03 12:27:55 PST
Landed in http://trac.webkit.org/changeset/191960