kandi background
Explore Kits

arthas | Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas

 by   alibaba Java Version: arthas-all-3.5.6 License: Apache-2.0

 by   alibaba Java Version: arthas-all-3.5.6 License: Apache-2.0

Download this library from

kandi X-RAY | arthas Summary

arthas is a Java library typically used in Institutions, Learning, Administration, Public Services applications. arthas has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can download it from GitHub, Maven.
Arthas is a Java Diagnostic tool open sourced by Alibaba. Arthas allows developers to troubleshoot production issues for Java applications without modifying code or restarting servers.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • arthas has a medium active ecosystem.
  • It has 28539 star(s) with 6268 fork(s). There are 1133 watchers for this library.
  • There were 1 major release(s) in the last 6 months.
  • There are 169 open issues and 1292 have been closed. On average issues are closed in 38 days. There are 46 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of arthas is arthas-all-3.5.6
arthas Support
Best in #Java
Average in #Java
arthas Support
Best in #Java
Average in #Java

quality kandi Quality

  • arthas has 0 bugs and 0 code smells.
arthas Quality
Best in #Java
Average in #Java
arthas Quality
Best in #Java
Average in #Java

securitySecurity

  • arthas has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • arthas code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
arthas Security
Best in #Java
Average in #Java
arthas Security
Best in #Java
Average in #Java

license License

  • arthas is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
arthas License
Best in #Java
Average in #Java
arthas License
Best in #Java
Average in #Java

buildReuse

  • arthas releases are available to install and integrate.
  • Deployable package is available in Maven.
  • Build file is available. You can build the component from source.
  • Installation instructions, examples and code snippets are available.
  • arthas saves you 23837 person hours of effort in developing the same functionality from scratch.
  • It has 48964 lines of code, 4741 functions and 642 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
arthas Reuse
Best in #Java
Average in #Java
arthas Reuse
Best in #Java
Average in #Java
Top functions reviewed by kandi - BETA

kandi has reviewed arthas and discovered the below as its top functions. This is intended to give you an instant insight into arthas implemented functionality, and help decide if they suit your requirements.

  • Render object .
  • Read a single character .
  • binds a port
  • Sample threads from origin threads .
  • Direct view to direct view
  • Compares two arrays .
  • Process the received option .
  • Get all classes in a package
  • Connect to arthas server
  • Returns a stacktrace for the given threadinfo

arthas Key Features

Check whether a class is loaded, or where the class is being loaded. (Useful for troubleshooting jar file conflicts)

Decompile a class to ensure the code is running as expected.

View classloader statistics, e.g. the number of classloaders, the number of classes loaded per classloader, the classloader hierarchy, possible classloader leaks, etc.

View the method invocation details, e.g. method parameter, return object, thrown exception, and etc.

Check the stack trace of specified method invocation. This is useful when a developers wants to know the caller of the said method.

Trace the method invocation to find slow sub-invocations.

Monitor method invocation statistics, e.g. qps, rt, success rate and etc.

Monitor system metrics, thread states and cpu usage, gc statistics, and etc.

Supports command line interactive mode, with auto-complete feature enabled.

Supports telnet and websocket, which enables both local and remote diagnostics with command line and browsers.

Supports profiler/Flame Graph

Support get objects in the heap that are instances of the specified class.

Supports JDK 6+.

Supports Linux/Mac/Windows.

Usages

Quick start

copy iconCopydownload iconDownload
curl -O https://arthas.aliyun.com/arthas-boot.jar
java -jar arthas-boot.jar

Feature Showcase

copy iconCopydownload iconDownload
$ thread -n 3
"as-command-execute-daemon" Id=29 cpuUsage=75% RUNNABLE
    at sun.management.ThreadImpl.dumpThreads0(Native Method)
    at sun.management.ThreadImpl.getThreadInfo(ThreadImpl.java:440)
    at com.taobao.arthas.core.command.monitor200.ThreadCommand$1.action(ThreadCommand.java:58)
    at com.taobao.arthas.core.command.handler.AbstractCommandHandler.execute(AbstractCommandHandler.java:238)
    at com.taobao.arthas.core.command.handler.DefaultCommandHandler.handleCommand(DefaultCommandHandler.java:67)
    at com.taobao.arthas.core.server.ArthasServer$4.run(ArthasServer.java:276)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

    Number of locked synchronizers = 1
    - java.util.concurrent.ThreadPoolExecutor$Worker@6cd0b6f8

"as-session-expire-daemon" Id=25 cpuUsage=24% TIMED_WAITING
    at java.lang.Thread.sleep(Native Method)
    at com.taobao.arthas.core.server.DefaultSessionManager$2.run(DefaultSessionManager.java:85)

"Reference Handler" Id=2 cpuUsage=0% WAITING on java.lang.ref.Reference$Lock@69ba0f27
    at java.lang.Object.wait(Native Method)
    -  waiting on java.lang.ref.Reference$Lock@69ba0f27
    at java.lang.Object.wait(Object.java:503)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)

Community Discussions

Trending Discussions on arthas
  • what may cause waiting state thread increase all the time in Java 8
Trending Discussions on arthas

QUESTION

what may cause waiting state thread increase all the time in Java 8

Asked 2020-Sep-24 at 16:06

Today I found my Java 8 apps have many thread is in WAITING state:

[arthas@1]$ thread --state RUNNABLE
Threads Total: 3427, NEW: 0, RUNNABLE: 17, BLOCKED: 0, WAITING: 3114, TIMED_WAITING: 296, TERMINATED: 0                                                                              
ID             NAME                                         GROUP                          PRIORITY       STATE          %CPU           TIME           INTERRUPTED    DAEMON         
124            pool-11-thread-25                            main                           5              RUNNABLE       75             0:0            false          false          
53             as-command-execute-daemon                    system                         10             RUNNABLE       23             0:0            false          true           
133            Thread-20                                    main                           5              RUNNABLE       1              0:2            false          true           
28             Apollo-RemoteConfigLongPollService-1         Apollo                         5              RUNNABLE       0              0:0            false          true           
32             Attach Listener                              system                         9              RUNNABLE       0              0:0            false          true           
99             DestroyJavaVM                                main                           5              RUNNABLE       0              0:39           false          false          
4              Signal Dispatcher                            system                         9              RUNNABLE       0              0:0            false          true           
19             grpc-default-worker-ELG-1-1                  main                           5              RUNNABLE       0              0:0            false          true           
21             grpc-default-worker-ELG-1-2                  main                           5              RUNNABLE       0              0:0            false          true           
97             http-nio-11003-Acceptor                      main                           5              RUNNABLE       0              0:0            false          true           
85             http-nio-11003-BlockPoller                   main                           5              RUNNABLE       0              0:0            false          true           
96             http-nio-11003-ClientPoller                  main                           5              RUNNABLE       0              0:0            false          true           
54             lettuce-nioEventLoop-4-1                     main                           5              RUNNABLE       0              0:0            false          true           
70             lettuce-nioEventLoop-4-2                     main                           5              RUNNABLE       0              0:0            false          true           
36             nioEventLoopGroup-3-1                        system                         10             RUNNABLE       0              0:0            false          false          
42             nioEventLoopGroup-3-2                        system                         10             RUNNABLE       0              0:0            false          false          
37             nioEventLoopGroup-4-1                        system                         10             RUNNABLE       0              0:0            false          false          
Affect(row-cnt:0) cost in 120 ms.

that have 3000+ thread is in WAITING state, now I pick a random WAITING thread pool thread, shows like this::

[arthas@1]$ thread 4410
"pool-96-thread-10" Id=4410 WAITING on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@3e27c029
    at sun.misc.Unsafe.park(Native Method)
    -  waiting on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@3e27c029
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1088)
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

Affect(row-cnt:0) cost in 16 ms.

but the problem is I don't know where started the thread and what make the waiting thread increase. Is there any way to find out where to start the thread or why the WAITING thread increase? I am now using Java ThreadExecutor. Right now the waiting thread is up to 6000+. I add a custom config:

@Configuration
public class ScheduleConfig implements SchedulingConfigurer {

    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        taskRegistrar.setScheduler(Executors.newScheduledThreadPool(30));
    }

}

enter image description here

ANSWER

Answered 2020-Sep-24 at 16:06

The stack trace you have shown is 'situation normal': That is a threadpool executor thread that is ready to do work, but the queue of work is empty. In this case, 'waiting' means: I'm waiting for a job to do, not: "I have stuff to do, but cannot do because I am waiting for stuff to be finished first".

Now, 3000 threads is itself somewhat of a concern; each thread has its own stack space. How large that is depends on your -Xss parameter, but they tend to go from 64k to 1MB. If it's 1MB, that's... 3GB of stack space, that's... suboptimal. This number (how many threads you have waiting around for a job to accept) should also not be growing much after a VM has heated up.

If all/most of those WAITING threads have a similar trace, then there are really only two options:

  • You made an executor and keep asking it, over time, to add more and more threads. I doubt this, but it's possible.
  • You keep making executors. Don't do this.

The idea behind an executor is that you make only one, or at least very very few of these.

If you MUST create them as part of your running app (vs. the normal thing, of creating jobs and feeding them to the singleton executor), then be aware they are effectively resources: if you don't 'close' them, your process will require more and more resources, until eventually the VM will crash when it runs out.

To close them, you invoke shutdown() which is asking nicely, and shutdownNow() which is more aggressive and will any not-yet-picked-up jobs permanently undone.

So, to recap:

  • You are making new executors during normal processing in your app. Search for new ScheduledThreadPoolExecutor in your codebase and inspect the situation. Add some logging if you must to see this in action.
  • Then, most likely, you want to fix this and stop making new executors in the first place - just make one, once, and feed jobs into this one executor.
  • If truly it makes sense to make them, use some guardian construct to ensure that you also clean them up when you're done using them. You can search for how to do so safely; it's a bit complicated, as you need to decide what to do with any jobs in the queue that are not yet done. If that's not an issue, it's easy: .shutdown() will get the job done.

Source https://stackoverflow.com/questions/64049987

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install arthas

Downloadarthas-boot.jar,Start with java command:.

Support

Online Tutorials(Recommended)User manualInstallationDownloadQuick startAdvanced usageCommandsWebConsoleDockerArthas Spring Boot StarterUser casesFAQCompile and debug/How to contributeRelease Notes

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Share this Page

share link
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.