Skip to content

CPU profiler not working #8999

@mauliktrapas

Description

@mauliktrapas

Need to do CPU profiling for Jruby application (jruby version : 1.7.20.1-8) which uses ruby version (1.9.3).
I tried using default profiler but getting below error due to version compatibility issue of tomcat and jdk.

app@sc-doc-prod-deployment-5cbd9f468-2bf2b:/usr/src/app$ uname -a
Linux sc-doc-prod-deployment-5cbd9f468-2bf2b 5.10.0-35-amd64 #1 SMP Debian 5.10.237-1 (2025-05-19) x86_64 GNU/Linux

app@sc-doc-preprod-deployment-7f4ddf6588-sxw9r:/usr/src/app$ jruby --profile -S ./bin/trinidad --ssl 37001 --config /etc/fk-sc-doc-b2b/trinidad.yml -p 37000
Profiling enabled; ^C shutdown will now dump profile info
Initializing ProtocolHandler ["http-bio-37000"]
Initializing ProtocolHandler ["http-bio-37001"]
Starting Servlet Engine: Apache Tomcat/7.0.28
Unable to process Jar entry [sun/security/ec/ECDHKeyAgreement.class] from Jar [jar:file:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/sunec.jar!/] for annotations
org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 18
at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:131)
at org.apache.tomcat.util.bcel.classfile.ConstantPool.(ConstantPool.java:60)
at org.apache.tomcat.util.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:209)
at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:119)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2049)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1931)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1899)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1885)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1281)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:855)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:346)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5172)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1595)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1585)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:750)
Unable to process Jar entry [sun/security/ec/ECDSAOperations.class] from Jar [jar:file:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/sunec.jar!/] for annotations
org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 18
at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:131)
at org.apache.tomcat.util.bcel.classfile.ConstantPool.(ConstantPool.java:60)
at org.apache.tomcat.util.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:209)

Please help me if I am doing anything wrong in profiler run command. as per error there is version in-compatibility with tomcat and jdk. how to fix this?

I tried using ruby-prof version (0.15.0), but getting below error.
Please suggest what to do. if ruby-prof can't work then please suggest any working alternative if you know

#35 43.77 Installing ruby-prof 0.15.0 with native extensions
#35 45.27
#35 45.27 Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
#35 45.27
#35 45.27 /usr/lib/jruby/bin/jruby -r ./siteconf20250903-10-1x1rtxq.rb extconf.rb
#35 45.27 /usr/lib/jruby/lib/ruby/shared/mkmf.rb:14: Use RbConfig instead of obsolete and deprecated Config.
#35 45.27 mkmf.rb can't find header files for ruby at /usr/lib/jruby/lib/native/include/ruby/ruby.h
#35 45.27
#35 45.27 extconf failed, uncaught signal 1
#35 45.27
#35 45.27 Gem files will remain installed in /usr/lib/jruby/lib/ruby/gems/shared/gems/ruby-prof-0.15.0 for inspection.
#35 45.27 Results logged to /usr/lib/jruby/lib/ruby/gems/shared/extensions/universal-java-1.8/1.9/ruby-prof-0.15.0/gem_make.out
#35 45.27 An error occurred while installing ruby-prof (0.15.0), and Bundler cannot
#35 45.27 continue.
#35 45.27 Make sure that gem install ruby-prof -v '0.15.0' succeeds before bundling.
#35 ERROR: process "/bin/sh -c bundle install" did not complete successfully: exit code: 5

I tried using async profier but it doesn't show ruby code info in CPU profiling. in this post https://www.ruby-forum.com/t/ruby-prof-for-jruby/149086 it was written that by enabling jruby.compile.mode=FORCE flag JVM profiler, it will work. but is not working. generated sample HTML file () and sample JFR file link - in this post https://www.ruby-forum.com/t/ruby-prof-for-jruby/149086

async_profiler_jruby_profiling.html

how to do the CPU profiling? Not able to figure out way to do this. please help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions