RFR: 8300273: [IR framework] Handle <!-- safepoint while printing --> message instead of bailing out
Tobias Hartmann
thartmann at openjdk.org
Mon Jan 30 06:59:16 UTC 2023
On Fri, 27 Jan 2023 09:31:40 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:
> This is yet another attempt to fix the IR framework in cases where the `tty` lock is broken for a safepoint. This time, however, I've decided to not add another bailout but to just rewrite the `hotspot_pid*` parsing code to completely parse everything. This means that `` messages are now skipped and then parsing continues for the reminder of a `PrintIdeal` output block.
>
> #### When are `tty` locks broken?
> This can only happen when dumping `PrintIdeal` for various compile phases. For `PrintOptoAssembly`, we have a `NoSafePointVerifier` object that ensures that we are not safepointing during the dump:
> https://github.com/openjdk/jdk/blob/f7da09c34918eea434c82af22b1da1f2a5b35f35/src/hotspot/share/opto/output.cpp#L1814-L1822
> The last interesting message printed by `LogCompilation` that needs to be parsed is the compilation queued message. This message is emitted in `CompileTask::log_task_queued()` where we also take the `tty` lock. Since we do not seem to safepoint during this method, I've added a `NoSafepointVerifier` object - just to be sure.
>
> #### Implementation details
> The idea is that we keep track of writer thread ids and currently parsed `PrintIdeal` blocks when parsing the `hotspot_pid*` file. If a new writer thread starts writing, it emits a `<writer thread='1683670'/>` message with the id. If that happens while we are still parsing a `PrintIdeal` block (i.e. not found the `</ideal>` end tag for the `<ideal ... />` opening tag), we store the currently parsed method (i.e. a `LoggedMethod` object) with its `WriterThread` in `WriterThread::saveLoggedMethod()`. When later parsing the same writer id again, we restore the method with `WriterThread::restoreLoggedMethod()` and continue parsing.
>
> Each line of a `PrintIdeal` output block is stored within a `CompilePhaseBlock` object. This class makes sure to remove any `` message (always at the end of a line with a line break) and to merge such a split line again.
>
> I've removed all previously added bailout fixes as they are not needed anymore with this fix.
>
> I've added some more classes and did some renamings to better structure the parsing steps.
>
> #### Testing
> On top of normal tier testing, I've added a separate test that parses a manually written `hotspot_pid*` file that simulates various cases of breaking the tty log and emitting the `` message with a line break.
>
> Thanks,
> Christian
This is hard to review but the solution makes sense and the code looks good to me. Some of the files still have copyright year 2022.
-------------
Marked as reviewed by thartmann (Reviewer).
PR: https://git.openjdk.org/jdk/pull/12246
More information about the hotspot-compiler-dev
mailing list