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

7264: Improve the performance of the JFR parser #266

Closed
wants to merge 2 commits into from

Conversation

jpbempel
Copy link
Member

@jpbempel jpbempel commented Jun 14, 2021

When parsing a JFR file, StackFrames are the objects that are the most
deserialized using Readers.
By default, JMC core parser used a generic ReflectiveReaders
which use reflection to parser the structure. However, we have known
objects like stack frames where we could directly map to the typed
object instead on relying on reflection, which speed up significantly
the parsing.

Here the results for c5.2xlarge instance single threaded parsing with 24MB jfr recording with 100 iterations:

runs baseline specific readers optim improvement
run 1 54,317ms 39,623ms -27%
run 2 54,988ms 39,520ms -28%
run 3 54,209ms 39,904ms -26%

Progress

  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JMC-7264: Improve the performance of the JFR parser

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jmc pull/266/head:pull/266
$ git checkout pull/266

Update a local copy of the PR:
$ git checkout pull/266
$ git pull https://git.openjdk.java.net/jmc pull/266/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 266

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jmc/pull/266.diff

When parsing a JFR file, StackFrames are the objects that are the most
deserialized using Readers.
By default, JMC core parser used a generic ReflectiveReaders
which use reflection to parser the structure. However, we have known
objects like stack frames where we could directly map to the typed
object instead on relying on reflection, which speed up significantly
the parsing.
@bridgekeeper
Copy link

bridgekeeper bot commented Jun 14, 2021

👋 Welcome back jpbempel! 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 label Jun 14, 2021
@mlbridge
Copy link

mlbridge bot commented Jun 14, 2021

Webrevs

@egahlin
Copy link
Member

egahlin commented Jun 14, 2021

I never thought reflection was a good idea, and It makes sense to have specialised logic for known types, but I don't think the code should rely on the field order.

In earlier release of JMC (4.1), there was similar specialiced logic as yours, but it broke once the "truncated" field was added to the stack trace struct in JDK 7. The same thing can happen again.

Back then, there was a field accessor class where the index was looked up when the parser was created. When the value was read the accessor could use the pre-calculated index to get the correct value. It might even have been bytecode generated for optimal performance.

@jpbempel
Copy link
Member Author

Agreed that this code is fragile.
I can precompute the index and make sure readers are meant for the field at construction time.
I will try that.

if unexpected field, fallbacks to reflective way
@thegreystone thegreystone requested a review from egahlin June 16, 2021 17:36
Copy link
Member

@egahlin egahlin left a comment

Choose a reason for hiding this comment

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

Looks reasonable, even though the code will not handle removal of a field, but it's perhaps not as likely, and may fail anyway in the UI layer.

@openjdk
Copy link

openjdk bot commented Jun 16, 2021

@jpbempel 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:

7264: Improve the performance of the JFR parser

Reviewed-by: egahlin

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 1 new commit pushed to the master branch:

  • 8e2988e: 7268: Show icons for modifiers in the method profiling page

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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 label Jun 16, 2021
@jpbempel
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Jun 16, 2021

Going to push as commit a2995a1.
Since your change was applied there has been 1 commit pushed to the master branch:

  • 8e2988e: 7268: Show icons for modifiers in the method profiling page

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Jun 16, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Jun 16, 2021
@openjdk
Copy link

openjdk bot commented Jun 16, 2021

@jpbempel Pushed as commit a2995a1.

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

@jpbempel jpbempel deleted the 7264 branch June 16, 2021 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants