RFR: 8374780: G1: Do not iterate klass metadata when splitting objArrays for every slice
Thomas Schatzl
tschatzl at openjdk.org
Mon Jan 12 10:24:27 UTC 2026
On Fri, 9 Jan 2026 09:22:53 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:
> this inconsistency in the API between `oop_oop_iterate_bounded` and `oop_oop_iterate_range` is unsettling. I think they both should be visiting the klass metadata if the obj falls within mr.
Not sure if it is an inconsistency if the API clearly spells out the difference between `_range` and `_bounded`:
`_range` gets array element indexes passed to it, so it is not possible that the given range can cover metadata, `_bounded` iterates a part of the entire object which contains metadata.
I can see your point about changing `_bounded` maybe not iterating over the metadata if it does not cover it.
As for checking whether the closure is not a metadata-processing one for `_range` is useful, but I would not recommend it for `_bounded` as this would likely just complicate code.
`InstanceKlass::oop_oop_iterate_reverse/backwards` is already kind of a special hack for G1/Parallel young gc as some benchmark(s) shows significantly better performance if doing so (iirc).
> src/hotspot/share/oops/objArrayOop.hpp line 86:
>
>> 84:
>> 85: public:
>> 86: // Special iterator for index ranges.
>
> This comment goes together with the one above in the objArrayKlass file. While looking at the various oop_oop_iterate functions in `ObjArrayKlass` I think it would be better if this was called `oop_iterate_elements`. Given the inconsistency described above, we might also have to do something about the `ObjArrayKlass::oop_oop_iterate_range` name. Let me take a closer look at these names separately from your patch.
I would keep the names consistent. Also maybe, to make its use abundantly clear, call it `oop_iterate_array_elements`. (The header could also be considered a element/part of the `objArray`).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29116#discussion_r2681629009
PR Review Comment: https://git.openjdk.org/jdk/pull/29116#discussion_r2681637521
More information about the hotspot-dev
mailing list