Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate perf impact of VirtualThread notifyJVMTI APIs #17508

Open
fengxue-IS opened this issue Jun 1, 2023 · 2 comments
Open

Investigate perf impact of VirtualThread notifyJVMTI APIs #17508

fengxue-IS opened this issue Jun 1, 2023 · 2 comments

Comments

@fengxue-IS
Copy link
Contributor

notifyJvmtiMount
notifyJvmtiUnmount

These calls are used in every VirtualThread transition, #17372 added FastJNI support to reduce the need of transition from JIT to VM. As these are only useful for synchronization when a JVMTI agent is attached, VM should detect if such path are actually used and avoid calling such if possible.

As a prototype, we should detect if JVMTI agent is attached, or allowed to attach during runtime (-XX:+EnableDynamicAgentLoading). if neither apply, then VM should skip the execution of these code and directly return.

@fengxue-IS
Copy link
Contributor Author

Starting point:

struct J9JavaVM {
    ...
    BOOLEAN agentEnabled;
}

// during vm init:
if ("-XX:-EnableDynamicAgentLoading" && "no agent attached on startup") {
    vm->agentEnabled = false;
} else {
    vm->agentEnabled = true;
}

// javanextvmi
JVM_VirtualThreadMountBegin(...) { // same apply to unmount & end
    if (vm->agentEnabled) {
        // execute original work
    }
}

agentEnabled can also be implemented as a vm flag if available.
hideframes(...) will need to be verified if it have effect for non-jvmti related code, if it does, then that can not be skipped.

@thallium
Copy link
Contributor

thallium commented Jun 7, 2023

Performance improvement (on my xLinux fyre vm):

  • Skynet: 1456.019 ±(99.9%) 46.318 ms/op -> 1402.605 ±(99.9%) 41.741 ms/op
  • PingPong: 2745.477 ±(99.9%) 120.398 ms/op -> 2482.003 ±(99.9%) 52.346 ms/op

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants