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

Use jfr parser from jdk mission control #1229

Merged
merged 10 commits into from
Apr 28, 2023
Merged

Conversation

laurit
Copy link
Collaborator

@laurit laurit commented Apr 19, 2023

No description provided.

@laurit laurit requested review from a team as code owners April 19, 2023 19:54
@laurit laurit requested a review from a team as a code owner April 20, 2023 16:37
Copy link
Contributor

@breedx-splk breedx-splk left a comment

Choose a reason for hiding this comment

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

Looks good overall, had a few thoughts/questions sprinkled throughout. Nothing too interesting....

I have a few hangups on this that I think we should discuss.

  1. I was a little surprised at the net increase in LOC. I kinda would have expected a reduction, but ok, it's approximately the same. Is the addition of the jmc dependency and all its I prefixed classnames worth it? It's certainly less readable....
  2. I know performance was likely to be a motivation behind this change, specifically reducing allocations which ultimately result in GC. Are there test numbers to back up this change as an improvement? Can those be shared?
  3. Does going this route prevent us from adopting the upstream/collab jfr-connection?
  4. Are we ok with this divergence from the community collab code? Do we think this ultimately makes things more compatible or less compatible in the mid/long term?

},
{
"bundleName": "UPL-BSD-3-Clause",
// org.openjdk.jmc:flightrecorder gets detected as UPL, it is really UPL+BSD dual license"
Copy link
Contributor

Choose a reason for hiding this comment

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

sadly, json doesn't support comments like this. An alternative would be to put it as a string in some other key that hopefully gets ignored.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Whatever parses this seems to be able to cope with such comments. Also tried adding comment as a field, but that failed because the parser tried to bind this to a class field that doesn't exist.

buffer = chunkLoader.call();
IItemCollection items = EventCollectionUtil.build(context.buildEventArrays());
items.stream().flatMap(iItems -> iItems.stream()).forEach(eventProcessingChain::accept);
eventProcessingChain.flushBuffer();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a behavior change. It used to flush after each file, now it's flushing after each chunk. Should this go back outside the loop?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In previous parser chunks were hidden so we used our own chunk tracker that called flushBuffer on chunk change. The behavior didn't change, just the flushBuffer call moved.

String methodName = method.getMethodName();
Integer lineNumber = frame.getFrameLineNumber();
if (lineNumber == null) {
lineNumber = -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

GDI spec says 0 when unknown.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, will change. Note that previous parser returned -1 when line number was not available

Copy link
Collaborator Author

@laurit laurit Apr 25, 2023

Choose a reason for hiding this comment

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

Replaced all occurrences of -1, please review.

@@ -88,108 +89,25 @@ void testLifecycle() {
inOrder.verifyNoMoreInteractions();
}

@Test
void testFlushOnChunkChange() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this is less interesting now that the chunk tracker exists elsewhere? Should we still verify that flush is called somewhere though?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this is covered with other tests, if flushBuffer is not called nothing will get exported with pprof.

@laurit
Copy link
Collaborator Author

laurit commented Apr 24, 2023

  1. I was a little surprised at the net increase in LOC. I kinda would have expected a reduction, but ok, it's approximately the same. Is the addition of the jmc dependency and all its I prefixed classnames worth it? It's certainly less readable....

I think if you exclude the added license files then there is no change in loc. It is true that the api of the previous parser is nicer, but considering that we need the profiling code to have minimal overhead everything that improves the situation is worth it, even if it comes at the cost of code readability.

  1. I know performance was likely to be a motivation behind this change, specifically reducing allocations which ultimately result in GC. Are there test numbers to back up this change as an improvement? Can those be shared?

I'll put together some stuff and paste it to slack.

  1. Does going this route prevent us from adopting the upstream/collab jfr-connection?

It doesn't. jfr-connection just returns a stream with jfr content, it doesn't affect the parsing. jfr-connection has a test that uses jmc parser. Currently I fail to see a reason why we would want to use jfr-connection.

Copy link
Contributor

@mateuszrzeszutek mateuszrzeszutek left a comment

Choose a reason for hiding this comment

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

Looks promising.

I'm a little bit worried about all the internal JMC classes that we use; but the JFR based implementation also depends on internal behavior (chunks) so it's not exactly a new thing.

@laurit laurit merged commit c2ab0c1 into signalfx:main Apr 28, 2023
@laurit laurit deleted the jfr-parser branch April 28, 2023 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants