2017tjp erik ostermuellercmgcanada.altervista.org/presentations/2018 apr pres/mtdp_ expos… ·...

32
Erik Ostermueller Author of Troubleshooting Java Performance http://bit.ly/2017tjp Author of Java performance certification exam at http://c0d3r.org java architect lead performance engineer FIS Global [email protected] @EOstermueller erikostermueller.com 1

Upload: others

Post on 09-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

Erik Ostermueller Author of

Troubleshooting Java Performance

http://bit.ly/2017tjp

Author of Java performance certification exam at

http://c0d3r.org

java architect

lead performance engineer

FIS Global

[email protected]

@EOstermueller

erikostermueller.com

1

Page 2: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

P.A.t.h Checklistwhere to look for

performance defects

● Persistence● Alien systems● threads● heap

2

Page 3: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

mTDpthe missing Visibility Tool

That will change everything

manual Thread Dump profiling

3

Page 4: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

The problem: How can I Troubleshoot

any running jvm?

4

Page 5: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

Don't need:● license for the expensive APM tool● JMX enabled● a java profiler installed● access to that environment

Any running JVM?Yes!!!!

5

Page 6: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

Finally troubleshootAnyRunningJVM

6

Page 7: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

Plug it in now!Don’t make me restart my JVMDon’t make me install stuff

7

Page 8: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

Why don’t more people use mTDp?● mTDp is hiding in a messy closet of

under-documented perf techniques ( Building Better Applications / 1994 )

● Perhaps mTDp is mathematically misconstrued?

http://ostermueller.blogspot.com/2017/04/the-math-behind-manual-thread-dump.html

8

Page 9: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

Thread Dumps: Old school and New schoolWithout mTDp, thread dumps diagnose these:

With mTDp we can solve many more problems!

9

Page 10: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

60 seconds on Thread Dump

the basic

10

Page 11: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

Jstack is low overhead

I use it regularly in prod and test

11

Page 12: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

Capture a Simple Thread DUmp

12

Page 13: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

Thread dump example: Jstack <myPid> or “kill -3”

13

Page 14: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

Landmarks in a Stack Trace (my terms)● Current - running on CPU when jstack was invoked● Trigger - your code that leads to ‘Current’ ● Entry - The protocol (HTTP, JMS) that started thread

14

Page 15: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

A Big Scary Stack Trace

15

Page 16: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

16

Page 17: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

17

Page 18: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

mTDp:A Description

18

Page 19: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

Take four or so thread dumps …as load is applied …with a few seconds between each

19

Step 1

Page 20: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

If something that you could fix…shows up in the dumps …for two or more threads …that are under load, then it is worth fixing!

20

Step 2

Page 21: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

A Visual of Four Thread Dumps

21

Page 22: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

mTDpTips

22

Page 23: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

Focus on Threads Under Load

(assume your code is the problem)

● Focus on all stack traces containing your package name!

● Focus on all stack traces started by your end users’ protocol.

If an HTTPS system, look for threads with an “entry” marked with HTTPS-ish class names.

23

Page 24: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

“web container” threads

24

Examples of HTTP Threads:

Page 25: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

● Which SQL statement is slow?● Slow backend system?● Great concurrency metric!● Great connection pool metric!● more!

Other mTDp Tricks:

25

Page 26: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

Common ways to mess up mTDp● Make judgements based on just one thread dump

FIX → take 4 or more

● Make judgements based on system with low-load or no-loadFIX → check for moderate CPU use

26

Page 27: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

Common ways to mess up mTDp (part 2)● Don’t lose focus of the threads under load.

○ If an HTTPS system, look for threads with an “entry” marked with HTTPS-ish class names.

○ If a JMS system, look for threads with an “entry” marked with JMS-ish class names.

● Thread dumps don’t show GC/heap problemsFIX → use jstat for a “plug-it-in-now” view of GC.

27

Page 28: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

Reminder: GC issues don’t show up in thread dumps

28

Page 29: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

Use vi and notepad++

Thread Dump analysis tools are great, but they limit you to the tip of the iceberg.

29

Page 30: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

mTDp can detect problems large (>1s) and small (2-3ms)

30

Page 31: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

mTDpDemo

31

Page 32: 2017tjp Erik Ostermuellercmgcanada.altervista.org/presentations/2018 Apr pres/mTDp_ Expos… · P.A.t.h Checklist where to look for performance defects Persistence Alien systems threads

THE ENDErik Ostermueller Author of

Troubleshooting Java Performance

http://bit.ly/2017tjp

Author of Java performance certification exam at

http://c0d3r.org

java architect

lead performance engineer

FIS Global

[email protected]

@EOstermueller

erikostermueller.com

32