> Greetings,
> 
> Please review this change to improve JFR’s reporting of JVMTI agents and, for 
> better separation of concerns, the responsibilities and lifetimes of JVMTI 
> agents.
> 
> ## Problem
> 
> Tools commonly reuse `Agent_OnAttach` as a control channel—for example, to 
> start and stop profiling. Previously, each successful startup invocation was 
> counted as a new agent instance, producing duplicate and misleading JFR 
> reporting.
> 
> This change associates reporting with JVMTI environment lifetimes established 
> during agent startup, while separating those lifetimes from library lookup 
> and `Agent_OnUnload` notifications.
> 
> For further details and a before-and-after profiling demonstration, see 
> [JDK-8392584](https://bugs.openjdk.org/browse/JDK-8392584).
> 
> ## Model and responsibilities
> 
> The model separates agent startup from loading its underlying OS library. An 
> agent startup invocation of an entry point may establish a new registered 
> agent instance or simply issue a command to an already existing agent.
> 
> The responsibilities are divided as follows:
> 
> - `JvmtiAgent` represents a startup invocation and holds its identity, JVMTI 
> environment association, startup state, and initialization timing.
> - `JvmtiAgentSet` manages startup attribution, JVMTI environment association 
> and disposal, and the append-only registry of registered JvmtiAgents.
> - `JvmtiResolver` represents shared library-resolution identity and manages 
> native-lookup eligibility and `Agent_OnUnload` registration.
> - `JvmtiAgentLifecycle` handles OS library loading, agent startup entry-point 
> resolution, invocation of startup entry-points, and unload notifications.
> 
> Dynamically loaded OS libraries are identified by their OS handles. 
> Statically linked JvmtiAgents are distinguished by normalized names.
> 
> ## JVMTI environment association and retention
> 
> The first successfully created JVMTI environment on the startup thread is 
> associated with the innermost executing startup invocation. This environment 
> becomes the `JvmtiAgent`'s identity over its lifetime.
> 
> The association has some constraints:
> 
> - Disposing the associated environment does not make the `JvmtiAgent` 
> eligible for reassociation.
> - Additional environments created by an inner startup invocation do not fall 
> through to an outer invocation.
> - Environment creation outside a startup invocation issued by the JVM does 
> not establish a tracked `JvmtiAgent` instance.
> 
> This direct association replaces attribution through callback addresses and 
> hardcoded knowledge of the JPLIS env...

Markus Grönlund has updated the pull request incrementally with one additional 
commit since the last revision:

  line break

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/33700/files
  - new: https://git.openjdk.org/jdk/pull/33700/files/892cb70d..904edff6

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=33700&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=33700&range=00-01

  Stats: 2 lines in 1 file changed: 1 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/33700.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/33700/head:pull/33700

PR: https://git.openjdk.org/jdk/pull/33700

Reply via email to