Java Performance Tuning
Java(TM) - see bottom of page
Our valued sponsors who help make this site possible
JProfiler: Get rid of your performance problems and memory leaks!
Training online: Concurrency, Threading, GC, Advanced Java and more ...
Tips May 2014
JProfiler
|
Get rid of your performance problems and memory leaks!
|
JProfiler
|
Get rid of your performance problems and memory leaks!
|
|
|
Back to newsletter 162 contents
https://plumbr.eu/blog/allocating-memory-for-the-jvm-a-case-study
Allocating memory for the JVM: a case study (Page last updated February 2014, Added 2014-05-28, Author Nikita Salnikov-Tarnovski, Publisher Plumbr). Tips:
- The main targets for tuning garbage collection are: 1) Modify the heap/permgen size; 2) Change the GC algorithm; 3) Configure the ratios between the memory regions.
- A reasonable estimate for initial heap size is 5 x live data set size, where the live data set size is the stabilised size of the heap used after full GCs.
http://www.appdynamics.com/blog/apm/agile-performance-testing-proactively-managing-performance/
Agile Performance Testing - Proactively Managing Performance (Page last updated March 2014, Added 2014-05-28, Author Steve Sturtevant, Publisher AppDynamics). Tips:
- Traditional performance engineering take time, and consist of: workload characterizations, capacity planning, script development, test user creation, test data development, multi-day soak tests, and more.
- Include performance engineering as a core part of your team.
- Build multiple performance and stress test scenarios with distinct goals and execution schedules: continuous integration performance tests (that can identify the impact of a specific code change); nightly integration performance tests; longer lasting stress tests in phase with sprints and the release schedule.
- Include generating performance test metrics from the Continuous Integration pipeline, e.g. with the Jenkins Performance Plugin.
- Define Key Performance Indicators that are quickly accessible and understood so that the team can immediately see when performance is inadequate after a change.
- Some useful Key Performance Indicators are: Percentile Response-Time - 90th, 95th, 99th - Summary and Per-Transaction; Throughput - Summary and Per-Transaction; GC Performance - % non-paused time, number of collections and collection times; Heap Utilization; Resource Pools sizes (e.g. Connection and Thread Pools).
- Ensure that your monitoring and testing tools don't degrade the performance of the things they measure.
http://apmblog.compuware.com/2014/03/25/network-performance-management-database-sap/
Using a Performance Management Database to Identify Network Problems that Impact SAP (Page last updated March 2014, Added 2014-05-28, Author Sebastian Kru, Publisher Compuware). Tips:
- Correlate long-term network performance data such as loss rate (packets dropped or retried) and round-trip time, with end-to-end transaction response times to identify network issues.
- [Interesting article on identifying that the number of storage containers held in warehouses decreases WiFi quality sufficiently to cause performance issues from degraded network quality].
- Measure real end-to-end request-response times (broken down across segments) to get the actual performance of your system, or you can easily miss issues and find it difficult to identify what and where they are being caused.
http://blog.jooq.org/2014/03/14/java-8-friday-goodies-lean-concurrency/
Java 8 Friday Goodies: Lean Concurrency (Page last updated March 2014, Added 2014-05-28, Author jOOQ, Publisher jOOQ). Tips:
- You can more simply execute methods in threads in Java 8 using lambdas, e.g.
new Thread(() -> {SOMESTATICMETHOD();})
and new Thread(SOMECLASS::SOMESTATICMETHOD)
- and then start the threads.
- Executing a collection of threads until termination in Java 8 is
Arrays.stream(threads).forEach(Thread::start);Arrays.stream(threads).forEach(t -> {try { t.join(); } catch (InterruptedException ignore) {}});
- A simple example of finding the maximum of a list of numbers in parallel in Java 8 - to illustrate the power of the language - is
Arrays.stream(new int[]{ 1, 2, 3, 4, 5, 6 }).parallel().max().ifPresent(System.out::println);
. Note this will internally use the ForkJoin framework without you needing to consider how.
- Being able to add the additional .parallel() call on a stream in Java 8 to parallelise processing without further code is a powerful improvement in making parallel execution of code simple.
http://www.infoq.com/articles/forkjoin-to-parallel-streams
From Imperative Programming to Fork/Join to Parallel Streams in Java 8 (Page last updated February 2014, Added 2014-05-28, Author Raoul-Gabriel Urma, Mario Fusco, Publisher InfoQ). Tips:
- [Article compares obtaining the variance of a collection of numbers using sequential processing; parallel processing with an explicit Forkjoin implementation; and parallel processing using Java 8 lambdas and streams]
- An explicitly implemented parallel procedure, while significantly more verbose and complicated than Java8 parallel streaming, may be faster [it's a micro-microbenchmark so I don't know how valid the result is].
http://www.javaspecialists.eu/archive/Issue217.html
Parallel Parking (Page last updated February 2014, Added 2014-05-28, Author Dr. Heinz M. Kabutz, Publisher The Java Specialists' Newsletter). Tips:
- If you have more than one field that need to be updated at the same time for the object to make sense, then the fields must be updated together atomically, either in a synchronized method or block, or by combining the field values into a single field that can be updated using a compare-and-swap atomic operation.
- Locking can outperform compare-and-swap (CAS) if the CAS fails often and requires many retries. But note that the locking alternative is only likely to outperform with a very high level of concurrency.
- A backoff before retrying when retrying failed compare-and-swap (CAS) operations can improve throughput, but only with a very high level of concurrency.
- The flag -XX:+DontYieldALot turns the Thread.yield() into a no-op on most current JVMs.
Jack Shirazi
Back to newsletter 162 contents
Last Updated: 2024-08-26
Copyright © 2000-2024 Fasterj.com. All Rights Reserved.
All trademarks and registered trademarks appearing on JavaPerformanceTuning.com are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries. JavaPerformanceTuning.com is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
URL: http://www.JavaPerformanceTuning.com/news/newtips162.shtml
RSS Feed: http://www.JavaPerformanceTuning.com/newsletters.rss
Trouble with this page? Please contact us