-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
8322142: JFR: Periodic tasks aren't orphaned between recordings #17114
8322142: JFR: Periodic tasks aren't orphaned between recordings #17114
Conversation
This issue is described on the jfr-dev mailing list here: https://mail.openjdk.org/pipermail/hotspot-jfr-dev/2023-December/005697.html With a minimal reproducer here: https://github.com/carterkozak/periodic-event-repro
👋 Welcome back carterkozak! A progress list of the required criteria for merging this PR into |
@carterkozak The following label will be automatically applied to this pull request:
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. |
I need to look more into this, and check things out manually, but what if BatchManager holds a SequencedSet of batches instead (LinkedHashSet). When active sorted task are iterated and getTask() doesn't return null, the batch is added to batches field. If it already exists, nothing happens, otherwise it is inserted. I guess we could end up with two batches with same period, but maybe the period could be the key. A TreeMap. |
I'm not certain what cases the BatchManager is optimized for, but I think the path forward depends quite a bit on that. array/ArrayList is difficult to outperform when inputs are small. TreeMap and LinkedHashSet both involve traversing many more pointers. I'm not sure how we want to weigh the benefit of reusing Batch objects between event disablement and reenablement against the higher traversal cost. If we did move from ArrayList to a SequencedSet, instead of adding the orphaned flag or re-adding the task, we could update the existing null check along these lines: - if (batch == null) {
+ if (batch == null || !batches.contains(batch)) {
batch = findBatch(task.getPeriod()); |
Someone might put 10 000 user-defined events in there. The purpose of the reuse is not reduce allocation, but to make the period stable. Flipping back and forth should not reset things. I need to run with logging to see if it looks OK. Hard to simulate in the brain. |
I don't think we have a complexity issue anymore. I was thinkings tasks/events, but batches should at most be 25. How would this work? If a batch with the same period exists, we reuse it, otherwise we insert it.
|
That makes sense, I'd thought you had meant 10,000 events with unique periods :-)
I don't think it's correct to assume
In this scenario, Event A will have a Batch reference with the same period as the batch used by Event B, so Perhaps we should update Sorry for slow responses today, I've been away from the computer -- I should have time to update this tomorrow. |
Cached batches from taks objects may be re-added.
Looks reasonable, but maybe this method signature would be easier to understand for someone that doesn't know the history?
|
Sounds good to me, I've applied your suggestion. I'd appreciate if you could give me some guidance on adding a test for this fix. I may be able fit my reproducer (updated with a 1ms period) into the format of the tests in Thanks for your help! |
It's hard to test in a reliable way. I would not add a test. Time is better spent fixing other issues than hunting down false positives. |
That works for me, thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update the title of PR so it matches the bug? I think a ':' is missing after "JFR".
I can sponsor the change.
After it has been integrated into main, it can be backported to JDK 21 and 22.
@carterkozak 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:
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 96 new commits pushed to the
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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@egahlin) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
@carterkozak |
/sponsor |
Going to push as commit 1551928.
Your commit was automatically rebased without conflicts. |
@egahlin @carterkozak Pushed as commit 1551928. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Thanks again @egahlin!
Would you like me to issue the backport commands? I'm not terribly familiar with the process, but I suspect |
Let's wait for the change to run through testing before backporting to JDK 22. If everything looks fine in a couple of weeks, we can also backport to JDK 21. Not sure about the targets, I will have to look it up. |
/backport jdk22 |
@egahlin the backport was successfully created on the branch backport-egahlin-15519285 in my personal fork of openjdk/jdk22. To create a pull request with this backport targeting openjdk/jdk22:master, just click the following link: The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:
If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk22:
|
This issue is described on the jfr-dev mailing list here:
https://mail.openjdk.org/pipermail/hotspot-jfr-dev/2023-December/005697.html
With a minimal reproducer here:
https://github.com/carterkozak/periodic-event-repro
Currently a draft because I don't have a ticket for this issue, and I haven't had a chance to add a test for this. I have verified that a build with this change resolves the bug I encountered.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17114/head:pull/17114
$ git checkout pull/17114
Update a local copy of the PR:
$ git checkout pull/17114
$ git pull https://git.openjdk.org/jdk.git pull/17114/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 17114
View PR using the GUI difftool:
$ git pr show -t 17114
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17114.diff
Webrev
Link to Webrev Comment