Initial configuration:
-startupplugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008. Jar-- Launcher.libraryplugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20150204-1316- Productorg.eclipse.epp. Package . Jee.product-showsplashorg.eclipse.platform-Vmargs-dosgi.requiredjavaversion=1.6- xms40m-xmx512m
View Code
Optimize the startup parameters previously monitored via Java VISUALVM, mainly:
- It happened 4 times FULLGC
- It happened 14 times MINORGC
This is the focus of our optimization, mainly to reduce FULLGC to 0, reducing the number of MINORGC
The first step:
Add the following parameters to the Eclipse.ini to output the GC log to the file:
-XX:+PrintGCTimeStamps-XX:+PrintGCDetails-Xloggc:gc.log
Content in Gc.log:
0.681: [GC (Allocation Failure) [psyounggen:10240k->1528k (11776K)] 10240k->2429k (39424K), 0.0083283 secs] [times : user=0.00 sys=0.00, real=0.01secs]0.987: [GC (Allocation Failure) [psyounggen:11768k->1528k (22016K)] 12669k->5986k (49664K), 0.0109152 secs] [times : user=0.06 sys=0.00, real=0.01secs]1.204: [GC (Allocation Failure) [psyounggen:22008k->1528k (22016K)] 26466k->14565k (49664K), 0.0291480 secs] [ times:user=0.09 sys=0.02, real=0.03secs]1.313: [GC (Allocation Failure) [psyounggen:22008k->1504k (42496K)] 35045k->23357k (70144K), 0.0263866 secs] [ times:user=0.13 sys=0.00, real=0.03secs]1.339: [Full GC (ergonomics) [psyounggen:1504k->0k (42496K)] [paroldgen:21853k->21409k (49664K)] 23357k-> 21409K (92160K), [metaspace:6760k->6760k (1056768K)], 0.1901100 secs] [times:user=0.64 sys=0.00, real=0.19secs]2.702: [GC (Allocation Failure) [psyounggen:40960k->1509k (42496K)] 62369k->28244k (92160K), 0.0098152 secs] [ times:user=0.05 sys=0.01, real=0.01secs]3.485: [GC (Metadata GC Threshold) [psyounggen:21650k->9716k (67584K)] 48385k->36459k (117248K), 0.0162970 secs] [ times:user=0.06 sys=0.00, real=0.02secs]3.502: [Full GC (Metadata gc Threshold) [psyounggen:9716k->0k (67584K)] [paroldgen:26742k->31170k (68608K)] 36459k->31170k (136192K), [metaspace:19718k->19718k (1069056K)], 0.1742468 secs] [times:user=0.48 sys=0.00, Real =0.17secs]6.650: [GC (Allocation Failure) [psyounggen:55296k->13299k (68608K)] 86466k->48886k (137216K), 0.0309857 secs] [ times:user=0.08 sys=0.01, real=0.03secs]6.990: [GC (Metadata GC Threshold) [psyounggen:33294k->12934k (91136K)] 68881k->48529k (159744K), 0.0413872 secs] [ times:user=0.09 sys=0.01, real=0.04secs]7.032: [Full GC (Metadata gc Threshold) [psyounggen:12934k->0k (91136K)] [paroldgen:35595k->40112k (87040K)] 48529k->40112k (178176K), [metaspace:32473k->32473k (1079296K)], 0.4352191 secs] [times:user=1.25 sys=0.16, Real =0.44secs]9.942: [GC (Allocation Failure) [psyounggen:73216k->18418k (91648K)] 113328k->59604k (178688K), 0.0228894 secs] [ times:user=0.08 sys=0.00, real=0.02secs]12.391: [GC (Metadata GC Threshold) [psyounggen:88358k->21486k (103424K)] 129544k->71185k (190464K), 0.0337033 secs] [times:user=0.09 sys=0.03, real=0.03secs]12.425: [Full GC (Metadata gc Threshold) [psyounggen:21486k->0k (103424K)] [paroldgen:49698k->68256k (131584K)] 71185k->68256k (235008K), [metaspace:52853k->52844k (1099776K)], 0.2803747 secs] [times:user=0.83 sys=0.00, Real =0.28secs]15.204: [GC (Allocation Failure) [psyounggen:81920k->13244k (109568K)] 150176k->81508k (241152K), 0.0245405 secs] [times:user=0.09 sys=0.00, real=0.02 secs]
View Code
Note: The Paroldgen part of the 4 FULLGC:
[ParOldGen: 21853K->21409K(49664K)][ParOldGen: 26742K->31170K(68608K)][ParOldGen: 35595K->40112K(87040K)][ParOldGen: 49698K->68256K(131584K)]
Conclusion: Thenodes that occur in FULLGC are the result of insufficient expansion of the old age.
The heap configuration in Eclipse.ini is as follows:
-Xms40m -Xmx512m
Step Two:
Modify the configuration to enlarge the old age capacity (PC memory 8G) as follows:
-Xms1024m -Xmx1024m -Xmn256m -XX:PermSize=256m -XX:MaxPermSize=256m
- The young generation is fixed to 128m, that is-xmn128m, and the old age is fixed.
- Fixed permanent generation to 96m (<JAVA8)
- Java8 no longer have the concept of perm, you need to configure
-XX:MetaspaceSize=256m
To restart Eclipse, log the following:
4.416: [GC (Allocation Failure) [psyounggen:196608k->32758k (229376K)] 196608k->47446k (1015808K), 0.0670608 secs ] [times:user=0.14 sys=0.09, real=0.0710.804: [GC (Allocation Failure) [psyounggen:229366k->32751k ( 229376K)] 244054k->89691k (1015808K), 0.0876533 secs] [times:user=0.27 sys=0.03, real=0.09 secs]
View Code
- There's no FULLGC! MINORGC is only 2 times!
Step Three:
GC Collector optimizations:
- As you can see from the log, the default is to use the PS-GC (Parallel scavenge + Parallel old), alias: ' Throughput first ' collector, which is suitable for scenarios where background operations do not require too many foreground interaction tasks, apparently as Eclipse collectors are not suitable!
So, consider replacing the GC collector, and the CMS (Concurrent-mark-sweep) is a collector that targets the shortest payback time, taking into account the frequent interaction with eclipse at work, which is obviously more suitable for use with CMS!
Here is the final configuration of this test:
-Startupplugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008. Jar--Launcher.libraryplugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20150204-1316-Productorg.eclipse.epp. Package. Jee.product-Showsplashorg.eclipse.platform-Vmargs-dosgi.requiredjavaversion=1.6-Xverify:none-xms1024m-xmx1024m-xmn256m-xx:metaspacesize=256m-xx:+USECONCMARKSWEEPGC-xx:+USEPARNEWGC-xx:+DISABLEEXPLICITGC-XNOCLASSGC-xx:cmsinitiatingoccupancyfraction=85--There's no perm in Java8.---xx:permsize=256m---xx:maxpermsize=256m-xx:+Printgctimestamps-xx:+printgcdetails-xloggc:gc.log
View Code
This study is based on an in-depth understanding of Java virtual machines. The second edition of the fifth chapter, Tuning case analysis and practice, thanks to the author's deep internal strength, more detailed information please refer to the original! Learning is a must drop!
Talk about eclipse tuning to reduce startup time