The "One Laptop Per Child" project has a great device ready to ship, but there's no Java on there. Let's think about working together to put Java on OLPC!
Replies:
17 -
Pages:
2
[
12
| Next
]
Threads:
[
Previous
|
Next
]
In my neverending quest to find the best JVM settings for running Eclipse I've been pouring over talks and papers given by Sun engineers and trying different things. Here are the best options that I've found so far for my 2-processor Windows machine running JDK5.0 and Eclipse3.1:
-vmargs -XX:+UseParallelGC
These go on the Eclipse executable's command line. What I'm doing here is taking advantage of the JDK5.0 garbage collection "ergonomics" feature to let the JVM self tune. It's only active with the UseParallelGC collector (also called the
parallel scavenge
collector). Note there is no -XmxNNNm option to set the heap size. According to the doc, any sizing or tweaking options will disable self tuning because it figures we know better than it does (it doesn't know us very well does it?).
If you want to see what the garbage collector is doing you could add more printing options like this (all on one line) to dump some logging information to a file that you can view or process later:
-vmargs -Xloggc:c:tempe.txt -XX:+PrintGCDetails -XX:+PrintGCTimeStamps
-XX:+PrintTenuringDistribution -verbose:gc -XX:+UseParallelGC
Here are some references if you want to do your own research:
1.At 5:23 PM
on Nov 18, 2004,
Alexander Staubo
wrote:
Re: Best JVM settings for Eclipse
A huge problem on Windows, completely overshadowing any JVM efficiency nuances, is the NT kernel's overzealous swapping of applications, especially of minimized applications, coupled with an allegedly inefficient page fault ordering algorithm.
The moment you minimize an app, Windows will start moving its working set onto disk. This results in a *lot* of disk trashing when you bring the app back into focus. I often have to wait 10-15 seconds for Eclipse; the same applies to other memory hogs such as Mozilla Thunderbird.
Fortunately, the KeepResident plugin has very nearly eliminated this problem:
Sad but true; Under 1.4.2 my pauses sometimes exceeded 200 seconds when coming back the next day to an iconified Eclipse. It feels better under JDK5 because JDK5's ergonomics keep trying to trim the VM size. I did try keepresident but it's a blunt instrument. Even with 1GB of real memory I can't afford to keep 200-300M permanently locked into the Eclipse process.
But consider that many large programs don't suffer the same problem. For example, if I run a big SAS job and it takes 500MB of memory and then gets paged out, it doesn't take a noticable amount of time to get itself paged back in enough to keep running when I return to it. I never have to wait long for, say, Visual Studio or Outlook. Could be an issue of the working set of a Java app being larger than a C app due to GC and bad locality of reference.
I remember somebody posted a patch to the SWT Display class that told Windows not to swap it out when it received the iconification message, but I couldn't locate the reference when I looked just now.
1.At 7:47 PM
on Nov 18, 2004,
Alexander Staubo
wrote:
Re: Best JVM settings for Eclipse
I can't explain the difference in swapping behaviour between programs. Locality of reference is one possible explanation, and this might be exacerbated by the VMM's FIFO page replacement policy:
Mozilla Thunderbird, which often runs above 100MB in VM usage, and Mozilla Sunbird, which hovers around 30MB, both exhibit the swapping problems, albeit to a slightly lesser degree than Eclipse.
I'm going to try start a Photoshop session and let it run minimized for a while.
Should be pretty easy to simulate a long minimization period, though, by doing a large VirtualAlloc() followed by a VirtualLock() -- Windows will minimize running applications' working sets when it runs out of physical memory.
1.At 12:29 AM
on Nov 19, 2004,
Alexander Staubo
wrote:
Re: Best JVM settings for Eclipse
Exactly. Do you have any idea whether the patch has been accepted? I've been running with the KeepResident plugin, so I wouldn't have noticed if recent builds had a fix.
It has not been. I coudn't find a bugzilla entry on it either. If you'd like to help out, open a new bug entry against Platform SWT and include the problems you're seeing and all this information we found.
Also Sun is making mods in Swing/AWT in J2SE6 to decrease the display cheese you get when an app is doing a long garbage collect. Won't help with Eclipse but it's still interesting:
http://java.sun.com/developer/community/chat/JavaLive/2004/jl1109.html (search for grey background)
I think the suggestion in the first reference about doing a System.gc() during the minimize might help. The problem seems to be that the app gets swapped out, and as soon as you start using it, it tries to do a garbage collect which is normally fast but thrashes Windows' paging algorithm when the app is paged out. Another way to say this is that the Java app needs an unusually large amount of working set immediately when you restore it, unlike non-gc'd apps.
Another way to avoid Windows' behavior of paging out memory belonging to the JVM is by turning off the paging file entirely... A drastic measure, yes, but if you have the RAM to spare it can be a nice luxury. In my case, my work machine has a gig of RAM, but I don't have Admin privileges on it so using the KeepResident plugin is not an option. Turning off virtual memory works well in this situation.
1.At 7:04 PM
on Feb 11, 2005,
Alexander Staubo
wrote:
Re: Best JVM settings for Eclipse
The swapping problem has been hitting me particularly hard lately. I did a few Bugzilla searches, and it looks like it's still unfixed on the trunk. So I finally submitted that bug report:
Guys,
I am having one issue whcich is reated to JVM size though I am not sure. I am rnning one java program(process which used to take 2 hr initially) from Eclipse as java application. This class is multithreaded program using Hibernate and allâ?¦ It used to run fine previously. While running this process after some changes in code now this process started giving error for â?? insufficient memory: full heap sizeâ?? I raised the heap size for javaw by setting eclipse setting but I guess that sets only the heap size for the eclpse and not for any javaw.exe fired from the eclipse. Any idea?? I will apreciate the help
Forgot to mention same code is running on one of my team mates m/c though he is using all default settings.
You need to change the VM options in the "launch configuration" that Eclipse uses when running your program. Select Run > Run... (or Run > Debug...) and find your configuration in the list (it's probably under Java Application). Click on the Arguments tab and look for VM Arguments. Type in -Xmx256m to increase your memory size to 256 megabytes for example, and click Apply, then Run or Debug. Hope this helps.
I found that ok, keepresident is good but sometimes crash eclipse (in my experience).
There is other thing I use on Windows and its tunes all applications via Memory Managment.
Most importat in MM is the registry key:
NonPagedPoolSize
it is located at
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management
The registry entry it is amount of memmory that MM should not to swap.
I have 1GB so I've set it to 1002438656 (decimal) it is near the 1GB. With that value swap file is used only when there is alocated more memory that the value, or for memmory blocks that were not used for let it say 2h. Anyway there is no swapint when I minimize applications or jump between them.
I also use the keepresident but without that option that is said that is unstable.
Has anyone out there performed any tuning on a single CPU (non-HT) machine? I'd also be interested in hearing results with other JVMs (eg. JRockit) - I tried JRockit 1.4 with Eclipse 3.0 a year or so ago, but didn't notice any difference in performance.
I'm not sure why many people are not aware of this setting, but there is an option in the registry to minimize how quickly Windows XP swaps apps to disk.
It's in the MemoryManagement section of the registry and the key is
DisablePagingExecutive
set the value to 1 and you'll wonder why no-one has told you about it before. It does the same thing as the KeepResident option. Anyhow, good luck.
Best JVM settings for Eclipse
At 12:11 AM on Nov 18, 2004, Ed Burnette
wrote:
-vmargs -XX:+UseParallelGC
These go on the Eclipse executable's command line. What I'm doing here is taking advantage of the JDK5.0 garbage collection "ergonomics" feature to let the JVM self tune. It's only active with the UseParallelGC collector (also called the parallel scavenge collector). Note there is no -XmxNNNm option to set the heap size. According to the doc, any sizing or tweaking options will disable self tuning because it figures we know better than it does (it doesn't know us very well does it?).
If you want to see what the garbage collector is doing you could add more printing options like this (all on one line) to dump some logging information to a file that you can view or process later:
-vmargs -Xloggc:c:tempe.txt -XX:+PrintGCDetails -XX:+PrintGCTimeStamps
-XX:+PrintTenuringDistribution -verbose:gc -XX:+UseParallelGC
Here are some references if you want to do your own research:
If you find something better, drop me a line. Enjoy!
17 replies so far (
Post your own)
Re: Best JVM settings for Eclipse
A huge problem on Windows, completely overshadowing any JVM efficiency nuances, is the NT kernel's overzealous swapping of applications, especially of minimized applications, coupled with an allegedly inefficient page fault ordering algorithm.The moment you minimize an app, Windows will start moving its working set onto disk. This results in a *lot* of disk trashing when you bring the app back into focus. I often have to wait 10-15 seconds for Eclipse; the same applies to other memory hogs such as Mozilla Thunderbird.
Fortunately, the KeepResident plugin has very nearly eliminated this problem:
http://suif.stanford.edu/pub/keepresident/
By the way, I wonder how well -XX:+UseParallelGC works with "hyperthreading" processors?
Re: Best JVM settings for Eclipse
Sad but true; Under 1.4.2 my pauses sometimes exceeded 200 seconds when coming back the next day to an iconified Eclipse. It feels better under JDK5 because JDK5's ergonomics keep trying to trim the VM size. I did try keepresident but it's a blunt instrument. Even with 1GB of real memory I can't afford to keep 200-300M permanently locked into the Eclipse process.But consider that many large programs don't suffer the same problem. For example, if I run a big SAS job and it takes 500MB of memory and then gets paged out, it doesn't take a noticable amount of time to get itself paged back in enough to keep running when I return to it. I never have to wait long for, say, Visual Studio or Outlook. Could be an issue of the working set of a Java app being larger than a C app due to GC and bad locality of reference.
I remember somebody posted a patch to the SWT Display class that told Windows not to swap it out when it received the iconification message, but I couldn't locate the reference when I looked just now.
Re: Best JVM settings for Eclipse
I can't explain the difference in swapping behaviour between programs. Locality of reference is one possible explanation, and this might be exacerbated by the VMM's FIFO page replacement policy:http://groups.google.com/groups?th=e9add7f6cba0837
Mozilla Thunderbird, which often runs above 100MB in VM usage, and Mozilla Sunbird, which hovers around 30MB, both exhibit the swapping problems, albeit to a slightly lesser degree than Eclipse.
I'm going to try start a Photoshop session and let it run minimized for a while.
Should be pretty easy to simulate a long minimization period, though, by doing a large VirtualAlloc() followed by a VirtualLock() -- Windows will minimize running applications' working sets when it runs out of physical memory.
Re: Best JVM settings for Eclipse
I found that Windows swap-you-out-when-minimized info I was looking for:http://dev.eclipse.org/mhonarc/lists/platform-swt-dev/msg03696.html
http://www.javagaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=Tuning;action=display;num=1090286158
http://support.microsoft.com/default.aspx?scid=kb;en-us;293215
Re: Best JVM settings for Eclipse
Exactly. Do you have any idea whether the patch has been accepted? I've been running with the KeepResident plugin, so I wouldn't have noticed if recent builds had a fix.Re: Best JVM settings for Eclipse
It has not been. I coudn't find a bugzilla entry on it either. If you'd like to help out, open a new bug entry against Platform SWT and include the problems you're seeing and all this information we found.Re: Best JVM settings for Eclipse
Some more references I found, one for Swing applications and one for Mozilla (a really long bugzilla entry):http://forum.java.sun.com/thread.jspa?forumID=57&messageID=2457849&threadID=515826
https://bugzilla.mozilla.org/show_bug.cgi?id=76831
Also Sun is making mods in Swing/AWT in J2SE6 to decrease the display cheese you get when an app is doing a long garbage collect. Won't help with Eclipse but it's still interesting:
http://java.sun.com/developer/community/chat/JavaLive/2004/jl1109.html (search for grey background)
I think the suggestion in the first reference about doing a System.gc() during the minimize might help. The problem seems to be that the app gets swapped out, and as soon as you start using it, it tries to do a garbage collect which is normally fast but thrashes Windows' paging algorithm when the app is paged out. Another way to say this is that the Java app needs an unusually large amount of working set immediately when you restore it, unlike non-gc'd apps.
Re: Best JVM settings for Eclipse
Another way to avoid Windows' behavior of paging out memory belonging to the JVM is by turning off the paging file entirely... A drastic measure, yes, but if you have the RAM to spare it can be a nice luxury. In my case, my work machine has a gig of RAM, but I don't have Admin privileges on it so using the KeepResident plugin is not an option. Turning off virtual memory works well in this situation.Re: Best JVM settings for Eclipse
The swapping problem has been hitting me particularly hard lately. I did a few Bugzilla searches, and it looks like it's still unfixed on the trunk. So I finally submitted that bug report:https://bugs.eclipse.org/bugs/show_bug.cgi?id=85072
Re: Best JVM settings for Eclipse
Guys,I am having one issue whcich is reated to JVM size though I am not sure. I am rnning one java program(process which used to take 2 hr initially) from Eclipse as java application. This class is multithreaded program using Hibernate and allâ?¦ It used to run fine previously. While running this process after some changes in code now this process started giving error for â?? insufficient memory: full heap sizeâ?? I raised the heap size for javaw by setting eclipse setting but I guess that sets only the heap size for the eclpse and not for any javaw.exe fired from the eclipse. Any idea?? I will apreciate the help
Forgot to mention same code is running on one of my team mates m/c though he is using all default settings.
Bye -
Raj
Re: Best JVM settings for Eclipse
You need to change the VM options in the "launch configuration" that Eclipse uses when running your program. Select Run > Run... (or Run > Debug...) and find your configuration in the list (it's probably under Java Application). Click on the Arguments tab and look for VM Arguments. Type in -Xmx256m to increase your memory size to 256 megabytes for example, and click Apply, then Run or Debug. Hope this helps.Re: Best JVM settings for Eclipse
I found that ok, keepresident is good but sometimes crash eclipse (in my experience).There is other thing I use on Windows and its tunes all applications via Memory Managment.
Most importat in MM is the registry key:
NonPagedPoolSize
it is located at
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management
The registry entry it is amount of memmory that MM should not to swap.
I have 1GB so I've set it to 1002438656 (decimal) it is near the 1GB. With that value swap file is used only when there is alocated more memory that the value, or for memmory blocks that were not used for let it say 2h. Anyway there is no swapint when I minimize applications or jump between them.
I also use the keepresident but without that option that is said that is unstable.
Re: Best JVM settings for Eclipse
Has anyone out there performed any tuning on a single CPU (non-HT) machine? I'd also be interested in hearing results with other JVMs (eg. JRockit) - I tried JRockit 1.4 with Eclipse 3.0 a year or so ago, but didn't notice any difference in performance.Re: Best JVM settings for Eclipse
I'm not sure why many people are not aware of this setting, but there is an option in the registry to minimize how quickly Windows XP swaps apps to disk.It's in the MemoryManagement section of the registry and the key is
DisablePagingExecutive
set the value to 1 and you'll wonder why no-one has told you about it before. It does the same thing as the KeepResident option. Anyhow, good luck.
http://technet2.microsoft.com/WindowsServer/en/library/3d3b3c16-c901-46de-8485-166a819af3ad1033.mspx?mfr=true
-Nathan