performance stories

technical essays about performance, life and everything ;)

Category: recipe

Software performance requirements are like happiness: everyone needs it, but it differs for everyone ;)

As we discussed in the previous post of this series we need to define what performance is exactly before starting any performance activity, i.e. formulate performance requirements.

Why?

Be aware of SUN Oracle Networking Properties or how to prevent hanging java.net.SocketInputStream.socketRead0……

There were a lot of emergencies in my practice with a very simple cause: one of the threads hung. And the single hanging thread isn’t so dangerous per se.

However

A real life example of finding memory leaks in java

Theory of finding memory leaks is pretty simple. I would formulate it as follows:

  1. Make sure it is a leak indeed;
  2. Identify leaking objects;
  3. Identify code lines, which prove a memory leak;
  4. Fix code.

There is a lot of articles about that. I remember a really great article: http://olex.openlogic.com/wazi/2009/how-to-fix-memory-leaks-in-java. I recommend it to everyone and thank it’s author.

If you got memory leak while doing performance testing, you are lucky. Usually, it’s very simple. Even if you use J2EE technologies, I mean, say, 80% of code, which is running on JRE, isn’t your team code (I mean container, various libraries, etc). I said simple, as you can reproduce it. Of course, there could be more difficult cases (JDK native code, lack of sources, etc.). But anyway, opportunity to reproduce is a serious bid for victory.

But what shall we do if there are no memory leaks while testing at all, in contrast to production environment with real user activities?

A couple of thoughts about Hibernate, caches and OQL

I was needed to clarify several things on Hibernate according to my work (what is a query cache? does it have regions? what is update timestamps cache? does it have regions or not?)

In general, there is a lot of articles, papers, notes, manuals, etc. One of the excellent examples is http://tech.puredanger.com/2009/07/10/hibernate-query-cache/.

So we got some understanding on query cache and update timestamps cache after reading: there is a query cache with query and bound variables as keys and update timestamps cache, that keeps a record corresponding to each table (was it modified or not later than query result was cached).

ok, I decided to see that with my own eyes

How to speed up java heap dump generation…

As you know, we need memory dump for a lot of things: memory leak analysis, memory footprint analysis (high memory footprint could be a problem sometimes) and to check/understand some details about our application.

However, in some circumstances heap dump generation can last tens minutes or even more. And all this time application is not available (yeah, we could set up a cluster, of course, but sometimes, it isn’t done). So that was my case, a server, which I had to get a memory dump from, was not clustered, heap size was about several gigabytes, jmap was used (jmap –F –dump:format=b…..), dump was stored to disk.

Next simple ideas helped me speed up dump generation more than 10 times:

read about ideas

ThreadLocal. Proceed with caution!

…Especially, when you have large-size objects and a lot of class loaders.

Why don’t I joke 😉

Yet another hanging java.net.SocketInputStream.socketRead0…

I’m going to tell you about one more emergency in our production environment.

So, we have a server with Glassfish, with 2 jdbc Oracle connection pools. One of these pools was usable, another wasn’t. Just was kept as a reminder of something ;). All external requests to this server were remote jdbc calls.

The symptoms of this emergency were:

  1. It was impossible to ping usable jdbc pool (GF console -> Resources -> JDBC -> Connection Pools -> General -> ping). I mean ping request was just hanging;
  2. Oracle DBAs saw no problems with sessions, connections, etc.;
  3. Unusable pool could be pinged easily;
  4. The servers, which were using this server, hung up in a special way: their http request handlers pools exhausted gradually, then the servers appeared hanging for some time, then were in working state again, then again from the beginning (exhausted, hung, working).

I had thread dumps as usual

How to restore line numbers after decompilation…

I use JD-GUI for decompilation to java now (http://java.decompiler.free.fr/). There is also JD-Eclipse, plugin for Eclipse.

It’s very nice tool. In general, it solves all my problems in this area. Yeah, of course, several times I got some methods decompiled not very good. And, of course, that were the most important methods for me at that moment. 🙂

However, there was more significant inconvinience for me (in both JD-GUI and JD-Eclipse, as they use the same core). Line numbers of decompiled code are not the same as line numbers of source code.

And this complicates debug process very much (breakpoints, etc).

%d bloggers like this: