RFR: 8373114: Redundant MethodCounters in the preimage generated by training run [v2]

Ashutosh Mehra asmehra at openjdk.org
Wed Dec 10 21:29:01 UTC 2025


On Wed, 10 Dec 2025 06:35:33 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> > Another approach I thought of was to add the filtering in ArchiveBuilder::get_follow_mode such that only the MethodCounters referenced by MTDs are stored in the AOTCache. It is possible to get the enclosing MetaspaceObj for the MetaspaceClosure::Ref passed to get_follow_mode but I couldn't find an easy way to get the type of the enclosing object, which makes it difficult to check if the MethodCounters being added came from Method or MTD.

> 
> Hi Ashutosh, I've created a patch for finding the type of the enclosing obj:
> 
> https://github.com/iklam/jdk/commit/cef9437484e119fde1b4eb07a809b33d83e35bdd
> 
> Could you try to see if that works for you?
> 

@iklam thanks for the changes. This is indeed what I wanted and updated the patch with the following change:

          address enclosing_obj = ref->enclosing_obj();
          if (ref->enclosing_obj_msotype() == MetaspaceObj::MethodTrainingDataType) {
            return make_a_copy;
          }

But it seems like this is not sufficient.  With this approach number of MethodCounters are only 1142 while the MTDs are around 4k. This is because in `ArchiveBuilder::gather_one_source_obj` the MCs that are first reached from Method get stored in the `_src_obj_table` with `_follow_mode=set_to_null`. Subsequent visits to such MCs through MTDs are ignored.

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

PR Comment: https://git.openjdk.org/jdk/pull/28670#issuecomment-3639025756


More information about the hotspot-dev mailing list