Open ryanlevell opened 8 months ago
When you can't find the right book, use the title + Google API id, e.g.:
https://www.googleapis.com/books/v1/volumes?q=intitle:java%20performance%20Q3_QDwAAQBAJ
no optimization in the world is going to make the array-based code as fast as a different version that uses a hash map. A good algorithm is the most important thing when it comes to fast performance.
Sampling Profiler: Least amount of overhead by firing periodically. Before Java 8 the stack trace could only be obtained during safe points, e.g. blocked by sync lock or waiting for IO. A new interface AsyncGetCallTrace
was introduced in Java 8 and where async profilers come from. Now the profiler can get the stack trace at any time.
Some tools like async-profiler
can measure native code as well.
Instrumented Profiler: Alters bytecode and gives more beneficial information at the cost of being very intrusive. It is recommended to use a sampling profiler to narrow the search to a package or class, then use the instrumented profiler on that single package/class.
jvisualvm
has a built-in profiler that will show very different results. This is because it measure blocking that does not consume CPU time. Most profilers do no report method that are blocked. This is because they may not be optimizable, e.g. waiting for waiting for a network call to complete. Measuring blocked methods can often be toggled in most profilers.
-XX:ReservedCodeCacheSize=N
This is the maximum cache size.
On 64-bit machines with sufficient memory, setting the value too high is unlikely to have a practical effect on the application.
-XX:+PrintCompilation
Prints every line that is compiled that has information about what has been compiled.
timestamp compilation_id attributes (tiered_level) method_name deopt
%
The compilation is OSR. On Stack Replacement is when the compiled code replaces code that is still running.s
The method is synchronized.!
The method has an exception handler.b
Compilation occurred in blocking mode.n
Compilation occurred for a wrapper to a native method.
The printed lines may also contain:
made not entrant
Happens 1. When code optimization assumption is incorrect (e.g., due to an interface variable changing to a different instance) and 2. when code compiled by C1 has now been compiled to C2.made zombie
When all the objects referenced by compiled code that is now marked made not entrant
gas been garbage collected, it can be marked made zombie
and the code is removed from the code cache.
0
Interpreted code1
Simple C1 compiled code2
Limited C1 compiled code3
Full C1 compiled code4
C2 compiled code
C1 is a faster compiler. C2 is slower but makes better optimizations. Modern JVMs use both called tiered compilation.
-XX:CICompilerCount=N
The number of compiler threads. 1/3 of the threads for C1, the rest for C2.
Note: There is no need to modify this flag with modern versions of Java. For Docker, one consequence of early versions of Java 8 is that it would use the machine's full specs rather than what is provided for the Docker instance to calculate JVM parameters. This may be one place you will see this flag used.
Congrats on starting Java Performance by Scott Oaks, I hope you enjoy it! It has an average of unknown/5 stars and 0 ratings on Google Books.
Book details (JSON)
```json { "title": "Java Performance", "authors": [ "Scott Oaks" ], "publisher": "O'Reilly Media", "publishedDate": "2020-02-11", "description": "Coding and testing are generally considered separate areas of expertise. In this practical book, Java expert Scott Oaks takes the approach that anyone who works with Java should be adept at understanding how code behaves in the Java Virtual Machine—including the tunings likely to help performance. This updated second edition helps you gain in-depth knowledge of Java application performance using both the JVM and the Java platform. Developers and performance engineers alike will learn a variety of features, tools, and processes for improving the way the Java 8 and 11 LTS releases perform. While the emphasis is on production-supported releases and features, this book also features previews of exciting new technologies such as ahead-of-time compilation and experimental garbage collections. Understand how various Java platforms and compilers affect performance Learn how Java garbage collection works Apply four principles to obtain best results from performance testing Use the JDK and other tools to learn how a Java application is performing Minimize the garbage collector’s impact through tuning and programming practices Tackle performance issues in Java APIs Improve Java-driven database application performance", "image": "http://books.google.com/books/content?id=Q3_QDwAAQBAJ&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api", "language": "en", "categories": [ "Computers" ], "pageCount": 451, "isbn10": "1492056081", "isbn13": "9781492056089", "googleBooks": { "id": "Q3_QDwAAQBAJ", "preview": "http://books.google.com/books?id=Q3_QDwAAQBAJ&printsec=frontcover&dq=intitle:Java+Performance+Q3_QDwAAQBAJ&hl=&cd=1&source=gbs_api", "info": "http://books.google.com/books?id=Q3_QDwAAQBAJ&dq=intitle:Java+Performance+Q3_QDwAAQBAJ&hl=&source=gbs_api", "canonical": "https://books.google.com/books/about/Java_Performance.html?hl=&id=Q3_QDwAAQBAJ" } } ```