8354362: Use automatic indentation in CollectedHeap printing#24593
8354362: Use automatic indentation in CollectedHeap printing#24593jsikstro wants to merge 22 commits intoopenjdk:masterfrom
Conversation
|
👋 Welcome back jsikstro! A progress list of the required criteria for merging this PR into |
|
@jsikstro 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 70 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. ➡️ To integrate this PR with the above commit message to the |
|
@jsikstro The following labels 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 lists. If you would like to change these labels, use the /label pull request command. |
|
/label remove serviceability |
|
@jsikstro |
|
@jsikstro |
|
@jsikstro |
|
Ping @tstuefe regarding changes for |
Webrevs
|
|
Notes:
|
9fea46a to
c1140b8
Compare
|
@jsikstro Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
|
Sorry for the force-push, made a mistake when merging with master. No comments should have been removed. |
|
Thank you for looking at this @tstuefe! I've addressed some of your comments with new commits. I agree that we likely want to merge streamIndentor and StreamAutoIndentor in a follow up RFE, where it also would be good to look at making set_autoindent() private. I haven't looked into it, but it feels weird to have an indentation level on an outputStream and use it only explicitly via indent() and not via a StreamAutoIndentor. I think a good solution would be to only allow indentation via the StreamAutoIndentor API like you're proposing, and look into whether there should be some API for temporarily disabling indentation with a RAII object (or just some parameters to StreamAutoIndentor) if there are cases that require it. |
|
|
||
| class StreamAutoIndentor : public StackObj { | ||
| outputStream* const _os; | ||
| class StreamAutoIndentor : public streamIndentor { |
There was a problem hiding this comment.
Just a note, not a request for change: I would personally have used composition instead of inheritance here (of streamIndentor).
lkorinth
left a comment
There was a problem hiding this comment.
I think this looks great. Thank you.
You might want to run a bit more internal testing; it is too easy to write a test that looks for specific formatting in the logs.
Mostly unrelated to this change: I think that outputStream probably should have a version of fill_to that guarantees a separating space so that a trailing space does not need to be put before the call (it ought to be by far the most common case). That is clearly out of scope for this change however.
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
|
Thank you for the reviews! |
|
Going to push as commit cf96b10.
Your commit was automatically rebased without conflicts. |
Hello,
Currently, the CollectedHeap printing code (print_on and print_on_error, with calls "below") prepends spaces in messages in a way that only makes sense if you write the code and then check the output to see if you've done everything correctly. To make writing and maintaining printing code easy, I propose we move to a system where each printing method, starting at callers of print_on and print_on_error, uses the indentation API in outputStream and does not rely on prepending spaces like is done right now.
What I propose is that any (GC) printing method should not make any assumptions of the indentation level of its caller(s). This means that each function shall:
Combining these two rules means that any (GC) printing method can be called from anywhere and give sensible output, without (seemingly random) indentation of expectations elsewhere.
I have aggregated calls that print on the same indentation level to the same callsite. This makes it clear where to look in the code and also makes it easier to add/enforce indendation. To this end, I have re-arranged print_on_error so that it never includes print_on. The new system I propose is that print_on and print_on_error can be called separately for different information, which aligns well with having the same callsite for the same indentation. See changes in vmError.cpp for how this is implemented.
Instead of prepending spaces, I use StreamAutoIndentor, defined in ostream.hpp. To make using automatic indentation easier, I've made some changes to StreamAutoIndentor so that it inherits from streamIndentor and also add an optional argument to StreamAutoIndentor to apply an indentation. My reasoning for this is that most places that use streamIndentor also want to use StreamAutoIndentor (either immediately or some time before) so that it is automatically applied. A downside of this change is that any previous uses of StreamAutoIndentor now also needs to store an extra int worth of memory. To me, this is a trade-off worth making, considering that memory for buffers of strings usually outweigh this extra memory cost. Additionally, when factoring in the improved code understandability and maintainability, I feel like it's a change worth making.
Some new changes in the way the printing looks are:
Code re-structure:
Testing:
-Xlog:gc+heap+exit=info-Xlog:gc+heap=debugjcmd <pid> GC.heap_infojcmd <pid> VM.info-XX:ErrorHandlerTest=14Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24593/head:pull/24593$ git checkout pull/24593Update a local copy of the PR:
$ git checkout pull/24593$ git pull https://git.openjdk.org/jdk.git pull/24593/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 24593View PR using the GUI difftool:
$ git pr show -t 24593Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24593.diff
Using Webrev
Link to Webrev Comment