5

I asked the same question in a different way and the question was closed : https://stackoverflow.com/questions/7231460/java-64-bit-or-32-bit
This is my 2nd try at getting an objective answer(s).

We were contemplating moving our product to 64-bit Java for those customers who are pushing the boundaries of the 32-bit server JVM on Solaris (SPARC) and Linux (RHEL 5.x). Our director asked "some years ago, 64-bit wasn't quite there. How about now?"

  1. For those customers not pushing the 4 GB boundary, will using 64-bit JVM have adverse effects in terms of performance? If yes, how much? We create a lot of objects. (we don't want to support 32-bit and 64-bit JVMs at the same time. It's a either or situation, preferably).

  2. For those pushing the 4 GB boundary, can we expect the JVM to be as stable as the 32-bit one?

    • Will performance be an issue? If yes, how much? we create a lot of objects.
    • What GC tuning techniques are new ?
    • Profilers: are they quite there for profiling 64-bit JVM apps?

UPDATE : To those commenters and those who closed my earlier question, I believe I NOW understand your angst. At the same time, I believe some of you made some (untrue) assumptions that I was lazy or a suit who has no clue. I'll post my findings after my investigations. Thanks to all those who gave me real pointers.

Community
  • 1
  • 1
anjanb
  • 12,999
  • 18
  • 77
  • 106
  • 6
    Seems like you got perfectly good answers on the other question you pointed to. They all tell the truth: that 99.9% of the time, 64-bit vs. 32-bit Java is a non-issue. Now, are there different ways of tuning the very large heaps that you can have with a 64-bit JVM? Maybe. But why not just ask that question, rather than this loaded laundry list. Most of these questions, frankly, make you sound like a suit who doesn't know what they're talking about. – Ernest Friedman-Hill Aug 30 '11 at 04:33
  • @Ernest Friedman Hill : thanks. I want to know how much performance hit I can expect from the latest 1.6 64-bit JVM. I want to know how stable the 64-bit vm is as compared to 32-bit JVM. I want to know any tooling issues. I got some answers but I didn't receive all the answers since the question got closed. I am NOW trying to ask more pointed questions to which I'm expecting specific answers. Suit : – anjanb Aug 30 '11 at 04:38
  • 1
    #4 is a bit ignorant, there is not 32-bit and 64-bit byte-code. The whole situation is pretty much an integration and testing-only exercise. – Steve-o Aug 30 '11 at 04:40
  • 2
    It's a bit concerning your "engg team" cannot spend a few minutes to profile a different JVM. You shouldn't have to ask these questions. – Steve-o Aug 30 '11 at 04:44
  • @Steve-o : we will probably validate each and every answer we receive but before we decide to spend a good chunk of time, wanted to know what the community has already learnt. – anjanb Aug 30 '11 at 04:51
  • @Ernest Friedman Hill : I've pruned it to the bare essentials. I had to re-read your question twice AND see the 3 "close" votes before I decided to prune it! – anjanb Aug 30 '11 at 05:10
  • @anjanb, question #1 cannot be answered unless you define adverse effects. Is a 5% loss in performance adverse or 10%? Also, the behavior of your app matters - do it create too many objects or too few; how is the memory on the heap actually getting consumed? I'm afraid that even the pruned list of questions cannot be objectively answered to provide a clear answer that would satisfy you, for it really is very open ended. [This](http://stackoverflow.com/q/1443677/3916) is an example of what I found expect in a question. To be honest, some of the questions sound like you haven't done research. – Vineet Reynolds Aug 30 '11 at 05:13
  • @Vineet Reynolds : Thank you. hmmm..... How about now ? – anjanb Aug 30 '11 at 05:24
  • Please compare this question with the closed one and then ask yourself: is it **significantly different** than your previous one? Simply re-phrasing a question doesn't make it less subjective. – Joachim Sauer Aug 30 '11 at 06:57

3 Answers3

5

Since you can pretty much do the testing yourself, I'm assuming you are expecting "real life" answers as to the experience of using a 32/64 bit JVM.

I'm part of a team which creates financial application for banks. We use 32 bit JVM's for development on Windows and almost all our server applications run on RHEL which runs a 64 bit JVM. Performance was never a problem for us since we use decent machines (our regular server machine use a 32 core AMD box with at least 32 GiB RAM).

As expected, the heap size would go up due to the difference in pointer sizes but since now the limit is raised from 4GiB, it again doesn't bother us. Our application also creates a lot of objects. We have no problem debugging our application with either VisualVM or command line tools. Regarding GC settings, we use the default settings and try to change only when we measure that it's actually the GC creating problems. Allocate a heap size which is much more than your application would use (8GiB) is common for us and you would see a single big GC sweep around once a day which is pretty good.

I've heard that the JDK 7 has a new GC algorithm called G1 garbage collector which is more suited for server applications so you should totally give it a try.

All that being said, your best bet would be to measure as much as possible (using 32 v/s 64 bit on 32 and 64 bit machines respectively) and then decide. FYI, our organization is totally pushing forward with the 64 bit JVM's given that most stock server hardware these days is 64 bits and 4GiB is pretty restrictive for a modern server application (at least in our domain).

Sanjay T. Sharma
  • 22,857
  • 4
  • 59
  • 71
  • thank you. I want to elicit real world experiences from others. Sure, we know how our app profiles in the current 32-bit JVM world but I wanted to understand if there were specific concerns that I needed to know. I've tried using the G1 on a smaller app earlier on a 1.6 JVM. as far as 1.7's concerned : we need to try it out before pushing it to production since it's very new and the Apache reports on it aren't very encouraging. – anjanb Aug 30 '11 at 05:49
  • Apache reports that some loop can be optimised incorrectly. The same bug appear in Java 6 as well except this optimisation is off by default. If you turn it off in Java 7 you get the same result and much the same performance as they have the same code base. Java 6 also has the G1 Collector for this reason. – Peter Lawrey Aug 30 '11 at 06:52
2

We were contemplating moving our product to 64-bit java for those customers who are pushing the boundaries of the 32- bit server JVM on Solaris(SPARC) and Linux(RHEL 5.x). Our director asked "some years ago, 64-bit wasn't quite there. How about now ?"

Sun have been doing 64-bit for much longer than Windows. Solaris 2.5 (1995 the same year Windows 95 was released) wasn't as reliable in 64-bit as it could have been. Many people still on SunOS (32-bit) didn't see the point and few machine has enough memory to matter. Solaris 2.6 (1997) saw the first significant migration to the 64-bit platform. I didn't use Java seriously until 1999 (on Solaris) and at that point 64-bit what already established in my mind.

1) For those customers not pushing the 4 GB boundary, will using 64-bit JVM have adverse effects in terms of performance ? if yes, how much ?

The 64-bit JVM has registers twice the size and twice as many. If you use long alot you can see a dramatic improvement, however for typical applications the difference is 5-10% either way.

we create a lot of objects.

IMHO Performance hasn't been much of an issue for you if this isn't recognised as a problem for you. Use any profiler and there are two reports CPU and Memory usage. Often examining the memory profile makes more of a performance difference. (See below)

(we preferably don't want to support 32-bit and 64-bit JVMs at the same time. It's a either or situation, preferably) Can't say there is much difference. What do you imagine is the overhead of supporting each. The code is exactly the same, from your point of view it might increase testing slightly. It not much different to supporting two versions of Java 6.

2) For those pushing the 4 GB boundary, can we expect the JVM to be as stable as 32-bit ?

Having used the 64-bit version since 1999 I can't remember an occasion where using the 32-bit would have made things better (only worse due to limited memory)

will performance be an issue ? if yes, how much ? we create a lot of objects.

If performance is an issue, discard less objects.

what GC tuning techniques are new ?

You can set the maximum memory size higher. That's about it. As long as you are below 32 GB there won't be a noticable increase in memory usage as it uses 32-bit references.

One thing I do is set the Eden size to 8 GB for a new application and reduce it if its not needed. This can dramatically reduce GC times. (To as low as once per day ;) This wouldn't be an option with a 32-bit JVM.

profilers : are they quite there for profiling 64-bit JVM apps ?

The VisualVM is pure Java and AFAIK works exactly the same. YourKit uses a native library and might need to ensure you are using the right version (it normally sets this up for you, but if you mess with your environment you might need to know there are two versions of the agent)


If you are worried about performance, don't create so many objects. You might be surprised how much slower creating objects freely makes in real world applications. It can slow an application by 2x to 10x or more. When I optimise code the first thing I do is reduce the discarding of object and I expect at least a three fold performance improvement.

By comparison using 64-bit vs 32-bit is likely to be 5%-10% difference. It can be faster or slower and both are just as likely. In terms of bloating your memory, use the latest JVMs and that is unlikely to be noticeable. This is because the 64-bit JVM uses 32-bit references by default when you use less than 32 GB of memory. The header overhead is still slightly higher but objects are not much bigger in 64-bit when -XX:+UseCompressedOops is on (the default for the latest releases).


Java: All about 64-bit programming

Test the size of common objects using 32-bit vs 64-bit JVMs Java: Getting the size of an Object

A extreme example of doing the same thing creating lots of objects and reflection vs not creating any and using dynamically generated code. 1000x performance improvement. Avoiding Java Serialization to increase performance

Using heap less memory can massively reduce your GC times. Collections Library for millions of elements

Using heap less memory can allow your application to use much more memory instead of passing data to another application Should server applications limit themselves to 4 GB?

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
1

There are so many aspects of your question that are dependent on your application that "real world" experiences with other peoples' applications are unlikely to tell you anything worthwhile with any degree of certainty.

My advice would be to stop wasting your time (and ours) asking what MIGHT happen, and just see what DOES happen when you use a 64-bit JVM instead of a 32-bit one. You are going to have to do the testing anyway ...

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216