Where to look for synchronized evidence in java?

Our Tomcat web application is slow when used by several hundred users. The servers are located in the hosting company, and their reports do not show any problems with the workload with bandwidth or processor, so I suspect that the reason for the slowdown may be due to disagreements on some outdated code that we encapsulated in synchronous calls, because it was an easier way.

I did some artificial tests in the development environment, changing synchronous calls with the ThreadLocal solution, and it gets faster, but I know that my boss will require me some evidence that he will also be faster in production.

How can I know for sure if the problem is with a conflict in the application?

+3
source share
6 answers

I think that the stream description kind of visualVM tool that comes with the latest Java 6 JDKs will be able to provide strong evidence (or against) your theory. It displays a pie chart for each thread, showing how much time it spends, works, sleeps, and waits on the monitor. You are interested in the latter (displayed in red):

alt text

+7
source

, , , , (, JMeter), . , , .

+3

Thare - java profilers , , , YourKit. , . ThreadLocals , , , .

, - , , (ctrl-break kill -QUIT), . , , . , TDA, Java, .

, - . , , , , , , .

+1
jstack PID

JVM , .

():

"AWT-XAWT" daemon prio=10 tid=0x0000000000e5f800 nid=0x476d runnable [0x00007f1a75616000..0x00007f1a75616bf0]
   java.lang.Thread.State: RUNNABLE
    at sun.awt.X11.XToolkit.waitForEvents(Native Method)
    at sun.awt.X11.XToolkit.run(XToolkit.java:543)
    at sun.awt.X11.XToolkit.run(XToolkit.java:518)
    at java.lang.Thread.run(Thread.java:636)

"Java2D Disposer" daemon prio=10 tid=0x0000000000d8b800 nid=0x476c in Object.wait() [0x00007f1a759df000..0x00007f1a759dfc70]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00007f1a82e2c3f8> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:133)
    - locked <0x00007f1a82e2c3f8> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:149)
    at sun.java2d.Disposer.run(Disposer.java:143)
    at java.lang.Thread.run(Thread.java:636)

. , , .

+1

,

//...
long t0 = System.currentTimeMillis();
synchronized(lockObj){
    logger.info("T sync :" + (t0 - System.currentTimeMillis()));
    //...
}

.

0
source

Your analysis sounds reasonable. Can you attach, for example, visualvm (in the JDK) for processes so that you can see where the time is spent?

0
source

Source: https://habr.com/ru/post/1714670/


All Articles