Su warm small talk JVM: Eclipse speed tuning

This series is used to record "in-depth understanding of the Java Virtual Machine" book study notes. Easy to see for yourself, but also facilitate access.

Haste makes waste To reach the haste makes waste!

Two days saw the JVM memory optimization, decided to try for Eclipse for memory tuning.
The machine uses a 64-bit Win10 systems, virtual machine Java HotSpot (TM) 64-Bit . Lenovo desktop hardware, Intel Pentium G630,8G physical memory.
A, Eclipse profile eclipse.ini

-startup
plugins/org.eclipse.equinox.launcher_www.shentuylzc.cn 1.4.0.v20161219-1356.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.www.tengyao3zc.cn win32.win32.x86_64_1.1.551.v20171108-1834
-product
org.eclipse.epp.package.www.xinyueylzc.cn  jee.product
-showsplash
org.eclipse.epp.package.www.huizhonggjpt.cn common
--launcher.defaultAction openFile --launcher.defaultAction openFile --launcher.appendVmargs -vmargs -Dosgi.requiredJavaVersion=www.lafei6d.cn  1.8 [email protected]/eclipse-workspace -XX:+UseG1GC -XX:+UseStringDeduplication --add-modules=ALL-SYSTEM -Dosgi.requiredJavaVersion=1.8 -Xms256m -Xmx1024m --add-modules=ALL-SYSTEM -Dcom.sun.management.jmxremote

The initial setting specifies the 1.8 version of the JDK, using G1 collector, set the maximum heap to 1024M and opened the JMX management.

Second, before tuning Health

Wrote a start timing eclipse plugin (the Jar package into the Eclipse plugins directory, start Eclipse, Eclipse can be displayed startup time), the time to start recording before optimization, in order to ensure the accuracy of test results, should finally start times once results:

è¿ is ?? ???? ???? å å æ ?? ???? ???? ¾ç è¿ °

è¿ is ?? ???? ???? å å æ ?? ???? ???? ¾ç è¿ °

Visual GC and plug-ins to get more information based on screenshots, we can conclude that the situation at the start original configuration:
1. Start consuming the entire 35 seconds.
2. Total time 1.126 seconds garbage collection, in which the Full GC 0 times, Minor GC 25 times, takes 1.126 seconds.
3. Load class 19991, took a total of 38.131 seconds.
4.JIT compile time of 46.103 seconds (as time goes by, the number of compile time and stop growth).
5. Virtual Machine 1024MB of heap memory is allocated for the new generation currently allocated 63M, years old 187M.
Overall not a short start-up time, so there is still room for tuning.


Third, the heap memory optimization and Metaspace

Open VisualVM, direct view memory curve

è¿ is ?? ???? ???? å å æ ?? ???? ???? ¾ç è¿ °

è¿ is ?? ???? ???? å å æ ?? ???? ???? ¾ç è¿ °

From the figure, regardless of the change curve of the Java heap or Mwtaspace curve, operations are completely normal.
Temporarily can not find the optimized conditions.

Fourth, the optimization of time and compile-time class load

看上图调优前的运行状况,编译时间和类加载时间应该是优化的重头戏了。

è¿ is ?? ???? ???? å å æ ?? ???? ???? ¾ç è¿ °

先看类加载时间。由于类加载需要进行字节码验证耗时,考虑到eclipse使用者众多,它的编译代码我们认为是可靠的,不需要加载的时候再进行字节码验证,因此通过参数-Xverify:none禁止掉字节码验证过程也可以认为是优化手段。

è¿ is ?? ???? ???? å å æ ?? ???? ???? ¾ç è¿ °

è¿ is ?? ???? ???? å å æ ?? ???? ???? ¾ç è¿ °

在取消掉字节码验证之后,确实可以看到Ecipse启动速度有了一定的提升,但仍还不够。
在类加载个数上,可以看出初始状况加载了19991个类,可以在eclipse中关掉不需要的启动项。

è¿ is ?? ???? ???? å å æ ?? ???? ???? ¾ç è¿ °

è¿ is ?? ???? ???? å å æ ?? ???? ???? ¾ç è¿ °

但是编译时间上目前没找到太好的办法~~~不知道怎么解决,希望有高人指点

五、调整内存,减少垃圾收集次数

上面说到了编译时间 类加载时间,那么剩下的就是GC时间了。
可以看出,此次Full GC被触发了 4 次,Minor GC 8 次。

è¿ is ?? ???? ???? å å æ ?? ???? ???? ¾ç è¿ °

此次GC次数并不算多,但是从监视器中可以看出,堆内存的使用不应该发生Full GC才对。
为了能够更好的看到eclipse启动期间所做的GC收集操作,我们加入配置-Xloggc:gc.log。

è¿ is ?? ???? ???? å å æ ?? ???? ???? ¾ç è¿ °

It can be seen every time a Full GC are all Metadata GC Threshold cause, which is caused by the element space full GC.
JDK8 start from the concept of permanent behalf (the PermGen) was discarded, and replaced by a called Metaspace storage space. Metaspace using a local memory instead of heap memory, which means that by default Metaspace only related to the size of the local memory size. Every Full GC, Metaspace are adjusted threshold. So, then add -XX: MetaspaceSize = 256M
but still can see Minor GC every time that happens is there is not enough memory caused by the new generation, therefore, still need to improve the configuration
** - Xms2048m
-Xmx2048m
-Xmn512m **
The tune preferably completed, only three Minor GC takes 600 milliseconds.
But the start-up time is still required 27 seconds. . . . . . . . . Gray often embarrassed.
Visual or time spent on class load and compile. The need for more further optimization. Finally, after the final eclipse.ini posted this tuning configuration
 

-startup
plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.www.baihua178.cn win32.win32.x86_64_1.1.551.v20171108-1834
-product
org.eclipse.epp.package.jee.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction openFile --launcher.defaultAction openFile --launcher.appendVmargs -vmargs -Dosgi.requiredJavaVersion=www.letianhuanchao.cn 1.8 [email protected]/eclipse-workspace --add-modules=ALL-SYSTEM -Dosgi.requiredJavaVersion=1.8 --add-modules=ALL-SYSTEM -Xms2048m -Xmx2048m -Xmn512m -Dcom.sun.management.jmxremote -Xverify:none -Xloggc:gc.log -XX:MetaspaceSize=256M 

 

Related Bowen:

Su warm small talk JVM: Java into the first chapter, the second chapter Java area of ​​memory and memory overflow exception, Chapter III garbage collector and memory allocation strategy

Su warm small talk JVM: Chapter VM performance monitoring and troubleshooting tool summary, Chapter V tuning case studies and practical

Su warm small talk JVM: class file structure Chapter VI, VII class loading mechanism, Chapter VIII bytecode execution engine

Guess you like

Origin www.cnblogs.com/laobeipai/p/12147220.html