{"id":20601765,"url":"https://github.com/c2nes/jtopthreads","last_synced_at":"2025-07-31T18:06:52.702Z","repository":{"id":57563192,"uuid":"330769894","full_name":"c2nes/jtopthreads","owner":"c2nes","description":"Show Java threads by CPU usage","archived":false,"fork":false,"pushed_at":"2021-01-24T17:04:55.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-17T01:48:06.660Z","etag":null,"topics":["go","golang","java","jstack","jvm","performance","top"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/c2nes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-18T19:44:06.000Z","updated_at":"2021-08-01T17:01:00.000Z","dependencies_parsed_at":"2022-08-31T05:01:48.650Z","dependency_job_id":null,"html_url":"https://github.com/c2nes/jtopthreads","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c2nes%2Fjtopthreads","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c2nes%2Fjtopthreads/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c2nes%2Fjtopthreads/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c2nes%2Fjtopthreads/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/c2nes","download_url":"https://codeload.github.com/c2nes/jtopthreads/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242241246,"owners_count":20095339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","java","jstack","jvm","performance","top"],"created_at":"2024-11-16T09:11:56.561Z","updated_at":"2025-03-06T16:20:23.282Z","avatar_url":"https://github.com/c2nes.png","language":"Go","readme":"\n`jtopthreads` prints Java stack traces ordered by CPU usage. It can be run against a running JVM or previously captured `jstack` output.\n\n## Installation\n\nFrom a directory outside of `$GOPATH` and without a `go.mod` file run,\n\n```\nGO111MODULE=on go get github.com/c2nes/jtopthreads@latest\n```\n\n## Usage\n\n``` shellsession\n$ jtopthreads -h\nusage: jtopthreads [options] \u003cstack-file\u003e [stack-file]\n   or: jtopthreads [options] [-sample \u003cduration\u003e] \u003cpid | main-class\u003e\n\n  -n N\n        limit output to the top N threads\n  -sample duration\n        sample process for duration\n  -summary\n        omit stacks\n```\n\n### Examples\n\nSample the process with the main-class `net.qrono.server.Main` for 5 seconds and print a summary (omitting stack traces) for the 10 busiest threads:\n\n``` shellsession\n$ jtopthreads -n 10 -summary -sample 5s net.qrono.server.Main\n[ 77.97%] \"epollEventLoopGroup-5-3\" #27 prio=10 os_prio=0 cpu=7653.72ms elapsed=10.29s tid=0x00007fdf6000b000 nid=0x1eb8 runnable  [0x00007fdf4e8f4000]\n[ 76.99%] \"epollEventLoopGroup-5-4\" #28 prio=10 os_prio=0 cpu=7659.95ms elapsed=10.29s tid=0x00007fdf60007000 nid=0x1eb9 runnable  [0x00007fdf4e7f3000]\n[ 43.22%] \"Thread-1\" #25 daemon prio=5 os_prio=0 cpu=15317.64ms elapsed=60.64s tid=0x00007fdf48001000 nid=0x1d07 runnable  [0x00007fdf4fffd000]\n[  0.79%] \"GC Thread#0\" os_prio=0 cpu=900.33ms elapsed=105.53s tid=0x00007fe01c042000 nid=0x1b7c runnable\n[  0.78%] \"GC Thread#3\" os_prio=0 cpu=919.06ms elapsed=59.57s tid=0x00007fdfe0114000 nid=0x1d0b runnable\n[  0.64%] \"GC Thread#1\" os_prio=0 cpu=1081.23ms elapsed=59.57s tid=0x00007fdfe0111000 nid=0x1d09 runnable\n[  0.60%] \"GC Thread#2\" os_prio=0 cpu=1009.09ms elapsed=59.57s tid=0x00007fdfe0112800 nid=0x1d0a runnable\n[  0.19%] \"VM Thread\" os_prio=0 cpu=119.19ms elapsed=105.48s tid=0x00007fe01d168000 nid=0x1b81 runnable\n[  0.08%] \"G1 Young RemSet Sampling\" os_prio=0 cpu=74.55ms elapsed=105.50s tid=0x00007fe01d106000 nid=0x1b80 runnable\n[  0.08%] \"grpc-default-worker-ELG-3-1\" #19 daemon prio=5 os_prio=0 cpu=299.90ms elapsed=104.77s tid=0x00007fdf58003000 nid=0x1b9c runnable  [0x00007fdfba8b5000]\n[201.25%] Total (elapsed 5.05s)\n```\n\nSame as above, but using previously captured `jstack` output (handy if you are grabbing data from a machine without `jtopthreads` installed):\n\n``` shellsession\n$ JVMID=$(jps -l | awk '$2 == \"net.qrono.server.Main\" {print $1}'); jstack \"$JVMID\" \u003e stack.0 \u0026\u0026 sleep 5 \u0026\u0026 jstack \"$JVMID\" \u003e stack.1\n\n$ jtopthreads -n 10 -summary stack.0 stack.1\n[ 81.82%] \"epollEventLoopGroup-5-5\" #29 prio=10 os_prio=0 cpu=7477.64ms elapsed=9.43s tid=0x00007fdf6000a000 nid=0x25eb runnable  [0x00007fdf4e6f1000]\n[ 80.03%] \"epollEventLoopGroup-5-6\" #30 prio=10 os_prio=0 cpu=7324.02ms elapsed=9.43s tid=0x00007fdf60008800 nid=0x25ec waiting for monitor entry  [0x00007fdf4e5f1000]\n[ 42.61%] \"Thread-1\" #25 daemon prio=5 os_prio=0 cpu=25618.41ms elapsed=431.62s tid=0x00007fdf48001000 nid=0x1d07 waiting on condition  [0x00007fdf4fffe000]\n[  0.17%] \"G1 Young RemSet Sampling\" os_prio=0 cpu=245.53ms elapsed=476.47s tid=0x00007fe01d106000 nid=0x1b80 runnable\n[  0.08%] \"VM Thread\" os_prio=0 cpu=264.03ms elapsed=476.46s tid=0x00007fe01d168000 nid=0x1b81 runnable\n[  0.06%] \"C2 CompilerThread0\" #6 daemon prio=9 os_prio=0 cpu=8711.94ms elapsed=476.44s tid=0x00007fe01d18d800 nid=0x1b86 waiting on condition  [0x0000000000000000]\n[  0.05%] \"C1 CompilerThread0\" #8 daemon prio=9 os_prio=0 cpu=1879.74ms elapsed=476.44s tid=0x00007fe01d18f800 nid=0x1b87 waiting on condition  [0x0000000000000000]\n[  0.03%] \"grpc-default-worker-ELG-3-1\" #19 daemon prio=5 os_prio=0 cpu=692.85ms elapsed=475.74s tid=0x00007fdf58003000 nid=0x1b9c runnable  [0x00007fdfba8b5000]\n[  0.03%] \"VM Periodic Task Thread\" os_prio=0 cpu=426.87ms elapsed=476.40s tid=0x00007fe01d240000 nid=0x1b89 waiting on condition\n[  0.02%] \"grpc-default-executor-0\" #20 daemon prio=5 os_prio=0 cpu=287.92ms elapsed=475.16s tid=0x00007fdf5c0b3800 nid=0x1ba2 waiting on condition  [0x00007fdfbafb8000]\n[204.76%] Total (elapsed 5.54s)\n```\n\nShow 3 busiest threads since application start up (not sampled):\n\n``` shellsession\n$ jtopthreads -n 3 net.qrono.server.Main\n[ 79.03%] \"epollEventLoopGroup-5-7\" #31 prio=10 os_prio=0 cpu=4235.79ms elapsed=5.36s tid=0x00007fdf60012000 nid=0x2f1d runnable  [0x00007fdf31ffb000]\n   java.lang.Thread.State: RUNNABLE\n        at io.netty.buffer.DefaultByteBufHolder.content(DefaultByteBufHolder.java:36)\n        at io.netty.handler.codec.MessageAggregator.decode(MessageAggregator.java:284)\n        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88)\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)\n        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)\n        at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:792)\n        at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:475)\n        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378)\n        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)\n        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)\n        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)\n        at java.lang.Thread.run(java.base@11.0.10/Thread.java:834)\n\n[ 78.34%] \"epollEventLoopGroup-5-8\" #32 prio=10 os_prio=0 cpu=4191.43ms elapsed=5.35s tid=0x00007fdf60014000 nid=0x2f1e runnable  [0x00007fdf31efa000]\n   java.lang.Thread.State: RUNNABLE\n        at com.lmax.disruptor.BlockingWaitStrategy.signalAllWhenBlocking(BlockingWaitStrategy.java:68)\n        at com.lmax.disruptor.SingleProducerSequencer.publish(SingleProducerSequencer.java:207)\n        at com.lmax.disruptor.RingBuffer.translateAndPublish(RingBuffer.java:1004)\n        at com.lmax.disruptor.RingBuffer.publishEvent(RingBuffer.java:555)\n        at net.qrono.server.Queue.enqueueAsync(Queue.java:139)\n        at net.qrono.server.redis.RedisChannelInitializer$RequestHandler.lambda$handleEnqueue$0(RedisChannelInitializer.java:123)\n        at net.qrono.server.redis.RedisChannelInitializer$RequestHandler$$Lambda$70/0x00000008001c4040.apply(Unknown Source)\n        at net.qrono.server.QueueManager$QueueWrapper.apply(QueueManager.java:160)\n        - locked \u003c0x0000000683652818\u003e (a net.qrono.server.QueueManager$QueueWrapper)\n        at net.qrono.server.QueueManager.withQueueAsync(QueueManager.java:115)\n        at net.qrono.server.redis.RedisChannelInitializer$RequestHandler.handleEnqueue(RedisChannelInitializer.java:122)\n        at net.qrono.server.redis.RedisChannelInitializer$RequestHandler.handleMessage(RedisChannelInitializer.java:337)\n        at net.qrono.server.redis.RedisChannelInitializer$RequestHandler.handleMessageSafe(RedisChannelInitializer.java:405)\n        at net.qrono.server.redis.RedisChannelInitializer$RequestHandler.channelRead0(RedisChannelInitializer.java:415)\n        at net.qrono.server.redis.RedisChannelInitializer$RequestHandler.channelRead0(RedisChannelInitializer.java:65)\n        at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99)\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)\n        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)\n        at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:792)\n        at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:475)\n        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378)\n        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)\n        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)\n        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)\n        at java.lang.Thread.run(java.base@11.0.10/Thread.java:834)\n\n[  4.35%] \"epollEventLoopGroup-5-5\" #29 prio=10 os_prio=0 cpu=18547.01ms elapsed=426.43s tid=0x00007fdf6000a000 nid=0x25eb runnable  [0x00007fdf4e6f2000]\n   java.lang.Thread.State: RUNNABLE\n        at io.netty.channel.epoll.Native.epollWait(Native Method)\n        at io.netty.channel.epoll.Native.epollWait(Native.java:148)\n        at io.netty.channel.epoll.Native.epollWait(Native.java:141)\n        at io.netty.channel.epoll.EpollEventLoop.epollWaitNoTimerChange(EpollEventLoop.java:290)\n        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:347)\n        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)\n        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)\n        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)\n        at java.lang.Thread.run(java.base@11.0.10/Thread.java:834)\n\n[ 20.26%] Total (elapsed 14m53.53s)\n```\n\n## Supported Platforms\n\n`jtopthreads` has only been tested with HotSpot. It supports Java 8 on Linux (live-capture only) and Java 11+ on other platforms. Analyzing previously captured `jstack` output is not supported on Java 8 due to the need to augment these pre-Java 11 captures with CPU usage data collected from `/proc`.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc2nes%2Fjtopthreads","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fc2nes%2Fjtopthreads","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc2nes%2Fjtopthreads/lists"}