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

8251046: [lworld] [lw3] C1 should avoid heap allocations in withfield when possible #137

Closed
wants to merge 10 commits into from

Conversation

@fparain
Copy link
Collaborator

@fparain fparain commented Aug 5, 2020

Please review this patch which reduces the number of heap allocations when executing the withfield bytecode with C1.
The CR linked below contains a more detailed description of the optimization:

CR: https://bugs.openjdk.java.net/browse/JDK-8251046

A rudimentary benchmark shows encouraging numbers:
Measuring inline type creation time with -XX:TieredStopAtLevel=1
Inline class Point has two int fields.
Inline class Rectangle has four int fields.

Without the optimization:
Benchmark Mode Samples Score Score error Units
o.s.MyBenchmark.testPointCreation avgt 200 7.573 0.027 ns/op
o.s.MyBenchmark.testRectangleCreation avgt 200 21.387 0.067 ns/op

With the optimization:
Benchmark Mode Samples Score Score error Units
o.s.MyBenchmark.testPointCreation avgt 200 5.284 0.014 ns/op
o.s.MyBenchmark.testRectangleCreation avgt 200 7.750 0.082 ns/op

Tested manually and with Mach5, tiers 1 to 3 (with Tobias' changes enabling more C1 testing).

Thank you,

Fred


Progress

  • Change must not contain extraneous whitespace

Issue

  • JDK-8251046: [lworld] [lw3] C1 should avoid heap allocations in withfield when possible

Reviewers

Download

$ git fetch https://git.openjdk.java.net/valhalla pull/137/head:pull/137
$ git checkout pull/137

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Aug 5, 2020

👋 Welcome back fparain! A progress list of the required criteria for merging this PR into lworld will be added to the body of your pull request.

@openjdk
Copy link

@openjdk openjdk bot commented Aug 5, 2020

@fparain This change now passes all automated pre-integration checks, type /integrate in a new comment to proceed. After integration, the commit message will be:

8251046: [lworld] [lw3] C1 should avoid heap allocations in withfield when possible

Reviewed-by: thartmann
  • If you would like to add a summary, use the /summary command.
  • To credit additional contributors, use the /contributor command.
  • To add additional solved issues, use the /issue command.

Since the source branch of this PR was last updated there have been 2 commits pushed to the lworld branch:

  • 660aa19: 8251107: [lworld] test lworld-values/TopInterfaceNegativeTest.java is failing
  • 349b22a: 8251116: [lworld] test lworld-values/ValuesAsRefs.java failing.

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid automatic rebasing, please merge lworld into your branch, and then specify the current head hash when integrating, like this: /integrate 660aa19eda768ef50cb2586b888d86491affc769.

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

@mlbridge
Copy link

@mlbridge mlbridge bot commented Aug 5, 2020

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Overall looks good to me, nice improvement! I've added some comments to the code.

@@ -419,6 +419,40 @@ void BlockBegin::state_values_do(ValueVisitor* f) {
}


StoreField::StoreField(Value obj, int offset, ciField* field, Value value, bool is_static,
Copy link
Member

@TobiHartmann TobiHartmann Aug 6, 2020

Choose a reason for hiding this comment

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

Indentation should be fixed.

}
}

StoreIndexed::StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before,
Copy link
Member

@TobiHartmann TobiHartmann Aug 6, 2020

Choose a reason for hiding this comment

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

Indentation should be fixed.

void GraphBuilder::stack_op(Bytecodes::Code code) {
switch (code) {
case Bytecodes::_pop:
{ state()->raw_pop();
{ Value w = state()->raw_pop();
NewInlineTypeInstance::update_stack_count(w);
Copy link
Member

@TobiHartmann TobiHartmann Aug 6, 2020

Choose a reason for hiding this comment

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

Wouldn't it be cleaner to use virtual calls on the Value class here?


virtual bool in_larval_state() const { return _in_larval_state; }
virtual void set_not_larva_anymore() {
_in_larval_state = false; }
Copy link
Member

@TobiHartmann TobiHartmann Aug 6, 2020

Choose a reason for hiding this comment

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

No newline needed after "{" or add newline before "}" as well.

@fparain
Copy link
Collaborator Author

@fparain fparain commented Aug 10, 2020

Hi Tobias!
Thank you for your feedback.
Code formatting has been fixed.
Adding virtual calls to the Value class forced to add null checks everywhere, so instead, updates of the inline type larvae are now performed in methods of the GraphBuilder class, encapsulating the null check.

Regards,

Fred

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Looks good to me. Thanks for making these changes!

@fparain
Copy link
Collaborator Author

@fparain fparain commented Aug 10, 2020

Thanks Tobias!

Fred

@fparain
Copy link
Collaborator Author

@fparain fparain commented Aug 10, 2020

/integrate

@openjdk openjdk bot closed this Aug 10, 2020
@openjdk openjdk bot added integrated and removed ready rfr labels Aug 10, 2020
@openjdk
Copy link

@openjdk openjdk bot commented Aug 10, 2020

@fparain The following commits have been pushed to lworld since your change was applied:

  • 660aa19: 8251107: [lworld] test lworld-values/TopInterfaceNegativeTest.java is failing
  • 349b22a: 8251116: [lworld] test lworld-values/ValuesAsRefs.java failing.

Your commit was automatically rebased without conflicts.

Pushed as commit 59d8f6b.

@fparain fparain deleted the c1_opt branch Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants