Current area: HOME -> Java -> Optimization Articles
Optimization
Build your own ObjectPool in Java to boost app speed
Object pooling allows the sharing of instantiated objects. Since different processes don't need to reinstantiate certain objects, there is no load time. And since the objects are returned to the pool, there is a reduction in garbage collection. Read on to learn, via the author's own example object pool design, how to employ this approach to boost performance and minimize memory use.
Compiler optimizations
Reggie Hutcherson shows you when compilers can help you optimize your code -- and when they can't. He also discusses the functioning of the more common optimizations supported across Java compilers: constant folding and dead code elimination.
Declarative Caching of Java Object Properties
Caching is a power mechanism for data access optimization, used for solving various problems. Caching is also very useful for developing program systems, saves calculation resources when a cached object property is accessed repeatedly. And the main complexities are not in caching itself, but in implementing timely cache actualization. To solve the task, the refreshable object library for Java was elaborated.
Design for performance, Part 1: Interfaces matter
Many common Java performance problems stem from class-design decisions made early in the design process, long before most developers even start thinking about performance. In this series, Brian Goetz discusses some common Java performance hazards and how to avoid them at design time.
Design for performance, Part 3: Remote interfaces
This is the last part of three-part article, Brian Goetz discusses some common Java performance hazards and explains how to avoid them at design time. In this article he examines performance issues specific to remote applications.
Develop a generic caching service to improve performance
In this article, you will learn how to create a 100 percent pure Java cache that uses an anonymous background thread to purge expired items. You will see how to architect such a cache while understanding the trade-offs involved with various designs.
Develop a generic caching service to improve performance
Java developers create applications that support thousands of concurrent users. To achieve high levels of scalability and performance for those users, applications must use services that cache resources such as lists and variables employed by multiple users. Because many developers don't know where to start when creating caching services, they often turn to third-party software to handle this seemingly complex task. In this article you will learn how to create those services yourself. The code presented here provides a caching service that is effective and ready to use.
Eye on performance: Micro performance benchmarking
Java performance enthusiasts Jack Shirazi and Kirk Pepperdine,
Director and CTO of JavaPerformanceTuning.com, follow
performance discussions all over the Internet to see what's
troubling developers. While surfing the Usenet newsgroup
comp.lang.java, they came across some interesting low-level
performance tuning questions. In this installment of Eye on
performance, they dive into some bytecode analysis to try and
answer some of these questions.
Eye on performance: Tuning garbage collection
If you're part of the current blogging craze, then you've likely heard of Blog-City, a blogging site owned and operated by Blog-City Ltd., a small company in Scotland. When some unexpected performance issues cropped up, Java performance experts Jack Shirazi and Kirk Pepperdine were asked to assist in a technical tuning of Blog-City. Their detective work was complicated by hardware constraints and communication channels (IRC, ftp, and the occasional e-mail) used throughout the project.
GC Portal-GC Tuning
The GC Portal enables analysis and performance tuning of Java applications from a garbage collection (GC) perspective by mining the verbose:gc logs generated by the JVM. GC Portal is a one-stop page for GC issues and includes an extensive collection of whitepapers, case studies and other material. The Portal is intended to be used with HotSpot JVM from Sun Microsystems, distributed as part of Java 2, Standard Edition (J2SE). Use of the GC Portal enables developers to model application and JVM behaviors from a GC perspective. This article introduces the design and features of the GC Portal, to enable developers to use it as a tool for analyzing and tuning GC.
Improve the robustness and performance of your ObjectPool
In our previous object-pooling article Thomas E. Davis presented an example object pool design and described how to employ this approach to boost performance and minimize memory use. This month, after providing a quick recap of object pooling, Thomas will show you how to enhance the example pooling utility to include exception propagation and the clean-up thread. Thomas finishes by addressing some reader comments about the first article.
Java performance programming, Part 1: Smart object-management saves the day
Excessive object creation can be a huge problem in Java programs. Despite continuing improvements in JVM technology for memory management, the object creation and garbage collection cycle is still a very expensive operation. If frequently used code creates excessive numbers of objects, performance can be slowed to a crawl as the JVM churns through, repeatedly creating and garbage collecting the objects. By understanding how to reduce the volume of object creation in your code, you can put an end to object churn and maximize the useful work you're getting out of the JVM.
Java Performance Urban Legends
Urban legends are kind of like mind viruses; even though we know they are probably not true, we often can't resist the urge to retell them (and thus infect other gullible "hosts") because they make for such good storytelling. Most urban legends have some basis in fact, which only makes them harder to stamp out. Unfortunately, many pointers and tips about Java performance tuning are a lot like urban legends -- someone, somewhere, passes on a "tip" that has (or had) some basis in fact, but through its continued retelling, has lost what truth it once contained. This article examines some of these urban performance legends and sets the record straight.
Java Performance: Efficiently Formatting Doubles
In my book Java Performance Tuning, I considered efficient ways to convert numbers to strings, and I provided conversion algorithms that are faster than those released with the Java SDK (up to and including version 1.3). In this article, I'll consider how to format doubles using a variation of that conversion algorithm, and show that the conversion of numbers with formatting can be faster than the original unformatted conversion.
Java Shared Classes
Java applications face a problem today: The only containment vessel available to them is the Java virtual machine (JVM) process itself. Multiple JVMs are required to isolate Java applications from each other, and this has two major negative impacts: start up time and memory. This article discusses the concepts behind shared classes in JVMs, how they work, and how this technology could potentially be exploited by users.
Lazy Programming
Lazy programming is a general concept of delaying the processing of a function or request until the results are needed. Thinking in terms of lazy programming can help you rid your code of unneeded computation and restructure programs to be more problem-oriented.
Load classes behind the scenes
Due to Java's runtime class loading, you can encounter many uncomfortable pauses when loading a Java applet or application. For many programmers, that is an unfamiliar performance problem, and the common solutions leave much to be desired. By intelligently loading classes in the background, however, your code can launch quickly and still remain responsive. This article shows you a simple technique for boosting perceived performance.
MegaJogos: The case of the fully utilized CPU
Do you like playing detective and solving mysteries?
Performance problems come in many guises, giving you ample
opportunity to indulge your clue-hunting proclivities to
identify and resolve them. The main man behind the MegaJogos
multi-player game site and a member of the Java Games
community, recently altered the application behind the site to
use the NIO package to enhance its scalability.
Memoization in Java Using Dynamic Proxy Classes
Memoization is a technique borrowed from functional programming
languages like Lisp, Python, and Perl for giving functions a
memory of previously computed values. Memoizing a function adds
a transparent caching wrapper to the function, so that function
values that have already been calculated are returned from a
cache rather than being recomputed each time. Memoization can
provide significant performance gains for computing-intensive
calls. It is also a reusable solution to adding caching to
arbitrary routines.
Micro-Tuning Step-by-Step
Micro-tuning is a term often used to mean speeding up small
sections of code out of context, by profiling and analyzing
that code and using some of the many techniques available to
make code run faster. In contrast, macro-tuning looks at the
program in context, and tries to improve performance by
altering the algorithms, data structures, or interactions
between components or subsystems. There is not always a
clear-cut distinction between these tuning methodologies;
micro-tuning is often a part of macro-tuning and the alteration
of algorithms and data structures is also a normal part of
micro-tuning. In this article, I will step through micro-tuning
a short method, using some standard techniques.
Optimize a query on a Map
In this article, the Author works through optimizing queries on Map classes. He uses a variety of performance-tuning techniques, showing the reasons some succeed while others fail. The techniques are directly applicable to most queries, and the results of those techniques show up to a tenfold speed increase
Optimize your Java application's performance
Many useful techniques exist for optimizing a Java program. Instead of focusing on one particular technique, this article considers the optimization process as a whole. Authors Erwin Vervaet and Maarten De Cock walk readers through the performance tuning of a puzzle-solving program, applying an assortment of techniques ranging from simple technical tips to more advanced algorithm optimizations. The end result is a spectacular performance increase (more than a million fold) between the first working implementation and the fully optimized solution.
Performance problem or design problem?
If your Java applications run slowly, poor design, and not so-called Java performance problems, is often to blame. Here are a few points to remember before you start to optimize.
Performance: Improve your development processes
Performance. It's the one aspect of the Java platform that
continually takes abuse. But the overwhelming success of the
platform on other fronts makes performance issues worth serious
investigation. In thisnew column, Intrepid optimizers follow
performance discussions all over the Internet, expanding and
clarifying the issues they encounter. This month, they head
over to the JavaRanch to cover discussions on compilation
speed, exceptions, and heap size tuning.
Recycle broken objects in resource pools
Many distributed (and some local) Java systems use resource pooling to improve performance. Resource pools may also be used when object resources are scarce and objects need to be shared between a number of clients. In this article, Philip and Nigel examine some of the issues involved in using resource pools and develop the recycler idiom, which is used to manage broken complex resources in an object pool. Using recyclers can improve the longevity and performance of Java server systems, for example, where robustness is a key design issue.
StringBuffer versus String
Reggie illuminates the underlying performance impact of using the StringBuffer and String classes when performing concatenations.
Tuning JDBC: Measuring JDBC performance
Java Database Connectivity (JDBC) is used extensively by many Java applications. In this article, the first of a series on performance-tuning JDBC, I look at how to measure the performance of JDBC and how to identify which parts of your JDBC subsystem need optimizing.
Tweak your IO performance for faster runtime
Increase the speed of Java programs by tuning IO performance. This article looks at some of the problems commonly encountered in performance tuning IO-bound Java applications
Use JDBC for industrial-strength performance, Part 1
The JDBC API provides three principal methods for calling a database to extract information. System performance and ease of maintenance depend on the usage scenario you choose. Integrating a Java server application with a legacy database system is a nontrivial task; evaluating system-usage scenarios and server-side patterns is important for creating fast, robust application systems. By using better server-side Java patterns for data mining, you can lighten the burden on system data storage. In this first article in a series, Lennart Jörelid discusses server-side Java patterns with JDBC. The reader is assumed to be familiar with the JDBC API.
What do you do when your tools are too fat?
Tuning isn't always about speed, sometimes other aspects of the application need fixing. When your application needs tuning, your first course of action is normally to monitor the application with a profiler. But profiling is not always practical -- sometimes for ironic reasons. In this installment of Eye on performance, Jack and Kirk relate their recent experiences with profiling a fat client -- so fat, in fact, that it left no room for a profiler.
Network Magazine Provides information Technology (IT) and network managers with strategic analysis, views of emerging technologies and product reports....
subscribe now