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

8322735: C2: minor improvements of bubble sort used in SuperWord::packset_sort #17190

Closed
wants to merge 3 commits into from

Conversation

D-D-H
Copy link
Contributor

@D-D-H D-D-H commented Dec 25, 2023

A minor improvement could be made for bubble sort in SuperWord::packset_sort to reduce the comparison count in bad cases.

See https://en.wikipedia.org/wiki/Bubble_sort


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8322735: C2: minor improvements of bubble sort used in SuperWord::packset_sort (Enhancement - P5)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17190/head:pull/17190
$ git checkout pull/17190

Update a local copy of the PR:
$ git checkout pull/17190
$ git pull https://git.openjdk.org/jdk.git pull/17190/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 17190

View PR using the GUI difftool:
$ git pr show -t 17190

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17190.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 25, 2023

👋 Welcome back ddong! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 25, 2023
@openjdk
Copy link

openjdk bot commented Dec 25, 2023

@D-D-H The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Dec 25, 2023
@mlbridge
Copy link

mlbridge bot commented Dec 25, 2023

Webrevs

@eme64
Copy link
Contributor

eme64 commented Jan 4, 2024

@D-D-H can you explain what this improves?

Ah, I think I see now. You want to decrease n quicker, by determining the highest index at which a swap took place.
First I would suggest that you rename newN -> max_swap_index.

And a more fundamental question:
Why do we need this improvement? Do you see any timing bottleneck and improvement? And what is faster: bubbling up or down?

And do you know why we sort at all in extend_packlist and why we do it again and again?

@D-D-H
Copy link
Contributor Author

D-D-H commented Jan 4, 2024

And a more fundamental question: Why do we need this improvement? Do you see any timing bottleneck and improvement? And what is faster: bubbling up or down?

And do you know why we sort at all in extend_packlist and why we do it again and again?

Sorry, I don't know the theory or implementation of superword. (I hope to grasp it someday...)

I just found it when browsing the code. This change is trivial; if you think it's unnecessary, I'm fine with closing it.

@eme64
Copy link
Contributor

eme64 commented Jan 5, 2024

Ok. This change is fine with me. Thanks for taking the time to look into this :)

I was just curious what was your motivation. I may completely redo this code once I remove the alignment constraints (here used for sorting), but that will have to be decided in a few months.

Please do the renaming, and then I can run testing and give you my approval.

@D-D-H
Copy link
Contributor Author

D-D-H commented Jan 5, 2024

Please do the renaming, and then I can run testing and give you my approval.

Updated. Thanks.

@eme64
Copy link
Contributor

eme64 commented Jan 5, 2024

@D-D-H nice. Testing running.

Copy link
Contributor

@eme64 eme64 left a comment

Choose a reason for hiding this comment

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

@D-D-H testing passed. Looks good. Thanks for the change!

@openjdk
Copy link

openjdk bot commented Jan 8, 2024

@D-D-H This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8322735: C2: minor improvements of bubble sort used in SuperWord::packset_sort

Reviewed-by: epeter, kvn

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 212 new commits pushed to the master branch:

  • 525063b: 8322878: Including sealing information Class.toGenericString()
  • c1282b5: 8323540: assert((!((((method)->is_trace_flag_set(((1 << 4) << 8))))))) failed: invariant
  • 5ba69e1: 8322477: order of subclasses in the permits clause can differ between compilations
  • c96cbe4: 8313083: Print 'rss' and 'cache' as part of the container information
  • a7db4fe: 8323428: Shenandoah: Unused memory in regions compacted during a full GC should be mangled
  • b86c3b7: 8309218: java/util/concurrent/locks/Lock/OOMEInAQS.java still times out with ZGC, Generational ZGC, and SerialGC
  • 475306b: 7057369: (fs spec) FileStore getUsableSpace and getUnallocatedSpace could be clearer
  • f016934: 8323518: Parallel: Remove unused methods in psParallelCompact.hpp
  • 2174f66: 8323005: Parallel: Refactor PSPromotionManager::claim_or_forward_depth
  • 1617067: 8323331: fix typo hpage_pdm_size
  • ... and 202 more: https://git.openjdk.org/jdk/compare/6dfb8120c270a76fcba5a5c3c9ad91da3282d5fa...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 8, 2024
@D-D-H
Copy link
Contributor Author

D-D-H commented Jan 8, 2024

@eme64
Thank you! Do I need a second review?

@eme64
Copy link
Contributor

eme64 commented Jan 8, 2024

Yes, I think that would be preferrable, even though this is not a very complicated fix.

@D-D-H
Copy link
Contributor Author

D-D-H commented Jan 8, 2024

Yes, I think that would be preferrable, even though this is not a very complicated fix.

Okay. Thanks.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Clever.

@@ -3526,12 +3526,11 @@ void SuperWord::packset_sort(int n) {
Node_List* t = q_i;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why you need this local t?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Deleted.

@@ -3526,12 +3526,11 @@ void SuperWord::packset_sort(int n) {
Node_List* t = q_i;
*(_packset.adr_at(i)) = q_low;
*(_packset.adr_at(i-1)) = q_i;
swapped = true;
max_swap_index = i;
Copy link
Contributor

Choose a reason for hiding this comment

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

So we not using i+1 here because all previous values should be < than i's
Right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.
The last i's value is > previous values and values between i and end are already sorted.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Good.

@D-D-H
Copy link
Contributor Author

D-D-H commented Jan 12, 2024

/integrate

Thanks for the review.

@openjdk
Copy link

openjdk bot commented Jan 12, 2024

Going to push as commit c5e7245.
Since your change was applied there have been 247 commits pushed to the master branch:

  • 65a0672: 8319773: Avoid inflating monitors when installing hash codes for LM_LIGHTWEIGHT
  • e22ab10: 8322537: Parallel: Remove experimental adjustment in PSAdaptiveSizePolicy
  • be900f1: 8323425: JFR: Auto-generated filename doesn't work with time-limited recording
  • 68c4286: 8323008: filter out harmful -std* flags added by autoconf from CXX
  • 7dc9dd6: 8234502: Merge GenCollectedHeap and SerialHeap
  • ed18222: 8323190: Segfault during deoptimization of C2-compiled code
  • 3e19bf8: 8323529: Relativize test image dependencies in microbenchmarks
  • ba23025: 8322957: Generational ZGC: Relocation selection must join the STS
  • 7c3a39f: 8323297: Fix incorrect placement of precompiled.hpp include lines
  • e72723d: 8323296: java/lang/Thread/virtual/stress/GetStackTraceALotWhenPinned.java#id1 timed out
  • ... and 237 more: https://git.openjdk.org/jdk/compare/6dfb8120c270a76fcba5a5c3c9ad91da3282d5fa...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jan 12, 2024
@openjdk openjdk bot closed this Jan 12, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 12, 2024
@openjdk
Copy link

openjdk bot commented Jan 12, 2024

@D-D-H Pushed as commit c5e7245.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants