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

High CPU Usage by TruffleCompilerThread #10730

Open
dandelion2 opened this issue Feb 21, 2025 · 4 comments
Open

High CPU Usage by TruffleCompilerThread #10730

dandelion2 opened this issue Feb 21, 2025 · 4 comments
Assignees
Labels

Comments

@dandelion2
Copy link

Describe GraalVM and your environment :

  • GraalVM version or commit id if built from source: 22.3.3
  • CE or EE: CE
  • JDK version: JDK11
  • OS and OS Version: ubuntu 20.04
  • Architecture: amd64
  • The output of java -Xinternalversion:
 **OpenJDK 64-Bit Server VM (11.0.20+8-jvmci-22.3-b22) for linux-amd64 JRE (11.0.20+8-jvmci-22.3-b22), built on Jul 19 2023 20:41:46 by "buildslave" with gcc 8.2.0**

Have you verified this issue still happens when using the latest snapshot?
You can find snapshot builds here: https://github.com/graalvm/graalvm-ce-dev-builds/releases

Describe the issue
During concurrent testing (100 threads), it was found that the CPU usage was excessively high, reaching nearly 300% on a 4-core CPU. Analysis revealed that three TruffleCompilerThread threads were responsible for this high usage. In the stress test code, both the context and the compilation results were cached to reduce redundant compilation.

Code snippet or code repository that reproduces the issue

Context context = contextManager.getContext(script, type);
Value value = context.getBindings("js").getMember(name);
if (value == null){
	context.eval("js",script);
	value = context.getBindings("js").getMember(name);
}
Object obj = value.execute(arguments).as(Object.class);
Object res = JSON.parse(JSON.toJSONString(obj));
return res;

Additional context
Current Invocation Method:java -jar -Dpolyglot.engine.OptimizationLevel=0 xxx.jar

Details
    Threads Total: 327, NEW: 0, RUNNABLE: 55, BLOCKED: 4, WAITING: 80, TIMED_WAITING: 164, TERMINATED: 0, Internal threads: 24                                                          
ID      NAME                                         GROUP                 PRIORITY       STATE          %CPU           DELTA_TIME     TIME           INTERRUPTED    DAEMON         
429     TruffleCompilerThread-429                    main                  10             RUNNABLE       99.71          0.204          13:22.927      false          true           
387     TruffleCompilerThread-387                    main                  10             RUNNABLE       99.59          0.204          13:22.452      false          true           
430     TruffleCompilerThread-430                    main                  10             RUNNABLE       98.72          0.202          13:22.234      false          true           
@selhagani
Copy link
Member

Hi @dandelion2,

Thank you for reaching out to us about this.
Could you please try retesting using the latest version of GraalVM? You can find it using this link: https://github.com/graalvm/graalvm-ce-builds/releases/

@selhagani selhagani self-assigned this Feb 21, 2025
@chumer
Copy link
Member

chumer commented Feb 21, 2025

Note -Dpolyglot.engine.OptimizationLevel=0 is not a valid option and does nothing. I am surprised it boots at all with this option.

Also, would you mind sharing a fully runnable example? Without the script executing we will not be able to reproduce this.

@dandelion2
Copy link
Author

Hi @dandelion2,

Thank you for reaching out to us about this. Could you please try retesting using the latest version of GraalVM? You can find it using this link: https://github.com/graalvm/graalvm-ce-builds/releases/

Hi @dandelion2,

Thank you for reaching out to us about this. Could you please try retesting using the latest version of GraalVM? You can find it using this link: https://github.com/graalvm/graalvm-ce-builds/releases/

Thank you for your suggestions. Due to certain reasons, we are not able to upgrade at the moment. Could you tell me what optimization parameters are available for multi-threaded script compilation in GraalVM Community Edition 22.3?

@chumer
Copy link
Member

chumer commented Feb 25, 2025

-Dpolyglot.engine.OptimizationLevel=0 does not exist in any version, did your LLM generate this suggestion?

We have lots of options documented here:
https://github.com/oracle/graal/blob/master/truffle/docs/Options.md#expert-engine-options

You can use:
-Dpolyglot.engine.Compilation=false to disable compilation entirely
and
-Dpolyglot.engine.Mode=latency for a more latency focused run-mode.

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

No branches or pull requests

3 participants