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 March 2009
JProfiler
|
Get rid of your performance problems and memory leaks!
|
JProfiler
|
Get rid of your performance problems and memory leaks!
|
|
|
Back to newsletter 100 contents
http://weblogs.java.net/blog/kohsuke/archive/2009/02/crash_course_on.html
Crash course on JVM crash analysis (Page last updated February 2009, Added 2009-03-30, Author Kohsuke Kawaguchi, Publisher java.net). Tips:
- For analysing crashes, start with the hs_err_pid*.log file that JVM creates upon a crash
- EXCEPTION_ACCESS_VIOLATION is the native equivalent to a NullPointerException
- The hs_err_pid*.log provides a stack showing where the crash occurred, including the native stack - but native stack generation is not always reliable so may have wrong information.
- Disassembling native code lets you identify where the native offset in a hs_err_pid*.log is in the native code.
- [Article searches through a stack dump and uses all the information to identify the parameters sent to the native method to determine what caused the native null pointer crash]
http://www.infoq.com/articles/Anti-Patterns-Alois-Reitbauer
Performance Anti-Patterns in Database-Driven Applications (Page last updated January 2009, Added 2009-03-30, Author Alois Reitbauer, Publisher infoQ). Tips:
- The design of adequate data-access logic is vital for achieving performance and scalability
- O/R mappers load data on a per-object basis. Coupled with lazy loading, this can lead to queries across collections of objects being hugely inefficient taking one query per object.
- O/R mappers can load much more data than required, causing serious memory, I/O and database load issues.
- Database connections are expensive and restricted resources, using them simplistically can lead to scalability issues.
- Data access patterns vary enormously for different parts of an application and at different times, and this needs to be considered and optimised for or resources get used suboptimally.
- Appropriate load testing is essential for identifying real issues.
http://java.dzone.com/articles/performance-monitoring-using
Performance Monitoring Using Glassbox (Page last updated March 2009, Added 2009-03-30, Author Viral Thakkar, Publisher JavaLobby). Tips:
- Glassbox is an open source web application which aid in performance monitoring and troubleshooting of multiple web applications deployed in container
- By default, an operation that takes more than 1 sec execution time is marked as SLOW status. Such SLA can be modified using Glassbox properties file.
- [Article walks through a simple example of using Glassbox].
http://www.kodewerk.com/test_doubles_for_performance_testing.htm
Test Doubles for Performance Testing (Page last updated February 2009, Added 2009-03-30, Author Kirk Pepperdine, Publisher kodewerk). Tips:
- A "Test Double" is a stub used to mock an external connection for performance testing a system without including actual external calls.
- A mocked call to an external connection needs to correctly simulate latency and local resource usage (e.g. parked threads) for performance tests.
- Simulated external connections should simulate appropriate randomly distributed latency and limitations of the actual external resources (e.g. limited number of requests allowed) - probably by using a queue and thread pool to control how many requests can be handled concurrently.
http://www.ociweb.com/jnb/jnbFeb2009.html
Google Collections, Part 2 (Page last updated February 2009, Added 2009-03-30, Author Dan Lewis, Publisher OCI). Tips:
- Sets do not allow repeated elements and do not preserve order. Arrays or Lists that have uniqueness checks around every add method are good candidates to be refactored to be Sets.
- Multisets (also known as bags) do allow repetition and do not preserve order. TreeMultiset keeps elements sorted according to their "natural" sort order.
- BiMaps require unique keys and values but provide an inverse view.
- Multimap allows keys to map to multiple values. Pass a key into get() on a Multimap and it will return a collection of all of the values associated with that key.
- Google Collections makes it easy to invert any Map or Multimap. Multimaps.forMap() converts any Map to a Multimap. Once you have a Multimap, call Multimaps.inverseHashMultimap(), Multimaps.inverseArrayListMultimap() or Multimaps.inverseTreeMultimap() for an inverted view.
- Google Collections provides a Constraint interface and some factory methods to apply constraints to existing collections, e.g. a set with null elements disallowed with Constraints.constrainedSet(set, Constraints.notNull());
http://www.javaworld.com/javaworld/jw-02-2009/jw-02-servlet3.html
Asynchronous processing support in Servlet 3.0 (Page last updated February 2009, Added 2009-03-30, Author Dr. Xinyu Liu, Publisher JavaWorld). Tips:
- Asynchronous support is Servlet 3.0's most significant enhancement, intended to make the server-side processing of Ajax applications much more efficient
- Persistent connections (HTTP 1.1) reduce communication lag perceptibly, because the client doesn't need to renegotiate the TCP connection after each request.
- Webserver memory consumption increases almost in direct proportion with the number of HTTP connections with a thread per connection model because threads are relatively expensive in terms of memory use.
- For many Web sites, users request pages from the server only sporadically - in a thread per connection model connection threads are idling most of the time, which is a waste of resources.
- NIO thread per request allows Web servers to handle a growing number of user connections with a fixed number of threads.
- When the asyncSupported attribute is set to true, the response object is not committed on method exit. Calling startAsync() returns an AsyncContext object that caches the request/response object pair. The AsyncContext object is then stored in an application-scoped queue. Without any delay, the doGet() method returns, and the original request thread is recycled. In the ServletContextListener object, separate threads initiated during application launch monitor the queue and resume request processing whenever the resources become available. After a request is processed, you have the option of calling ServletResponse.getWriter().print(...), and then complete() to commit the response, or calling forward() to direct the flow to a JSP page to be displayed as the result. Note that JSP pages are servlets with an asyncSupported attribute that defaults to false.
- High polling frequencies waste server resources and network bandwidth. It is more efficient for servers to actively push data to browsers - achievable with Servlet 3.0 and service streaming and long polling, known as Comet or reverse Ajax.
Jack Shirazi
Back to newsletter 100 contents
Last Updated: 2024-11-29
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/newtips100.shtml
RSS Feed: http://www.JavaPerformanceTuning.com/newsletters.rss
Trouble with this page? Please contact us