RFR: 8369039: JDK-8348611 caused regression in Javac-Hot-Generate [v3]

Chen Liang liach at openjdk.org
Wed Oct 8 14:11:03 UTC 2025


On Wed, 8 Oct 2025 13:50:55 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

>> @archiecobbs measured a win. I haven't seen it in profiles but it could be that the code in `afterAttr` contribute to the case for `LinkedList` as it is set up to remove matching item from the list, likely at an early index. Which is one of the few things a `LinkedList` actually does better than an `ArrayList`.
>
> While I agree `ArrayList`s are often better, @archiecobbs measured the `LinkedList`s perform better here, as @cl4es says.
> 
> I am not quite clear why linked lists are faster, but it might be many of the lists are either empty (all the `children` of the leaf `LintRange` instances will be empty lists, I think, and an empty `LinkedList` is, I think, cheaper than an empty `ArrayList`), and some of them will have only a few entries (like the `unmappedDecls` list here: AFAIK, this has one entry for each top-level declaration, and hence is highly unlikely to have more than 2 entries - one for the package clause, and one for the top-level class). If `ArrayList`s with substantial number of entries are only a small minority, it might explain why the use of `LinkedList`s leads to better results.

I think the right way to fix is not to use LinkedList, but to update afterAttr to use List.removeIf - this was added back in 8 to avoid the overhead of shifting from multiple removals.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/27651#discussion_r2413990365


More information about the compiler-dev mailing list