加速智能 J- 创意

我正在使用 telliJ 进行 Scala 开发,上周我得到了 8 GB的新内存,所以我想: 是时候使用它了。我检查了我的任务管理器,发现 intelliJ 使用 ~ 250mb。从 Eclipse 我知道调整 JVM 选项对提高速度有很大帮助,所以我谷歌了一下..。

并且发现这个是针对 OS X 的 我无法立即找到 JVM 选项,所以我开始在1GB 的位置调整 Xmx.,我意识到它不再启动了。我检查了 intelliJ 的 Java 版本,发现它已经过时了,而且是32位的。

因此,为了使用当前的 JDK 和 64位,必须将链接从:

IntelliJ IDEA Community Edition 10.0.2\bin\idea.exe

IntelliJ IDEA Community Edition 10.0.2\bin\idea.BAT

调整“开始”

蝙蝠寻找 JDK_HOME和使用64位现在。

我目前的 虚拟机选项,它位于

...\IntelliJ IDEA Community Edition 10.0.2\bin\idea.exe.vmoptions

-Xms512m
-Xmx1024m
-XX:MaxPermSize=512m
-ea
-server
-XX:+DoEscapeAnalysis
-XX:+UseCompressedOops
-XX:+UnlockExperimentalVMOptions
-XX:+UseParallelGC

可以使用 -XX:+UseConcMarkSweepGC代替 -XX:+UseParallelGC,即

桌面应用程序的公认选择, 但我改变了吞吐量 收藏家最近。因为与一个 快速的机器和足够小的堆, 你有更快的停顿,更多的吞吐量 没有分裂的问题 (ijuma. # scala)

变化:

-XX:+UseConcMarkSweepGC //removed
// removed, because not needed with the lastest JVM.
-XX:+UnlockExperimentalVMOptions
-XX:+DoEscapeAnalysis
-XX:+UseCompressedOops

我现在还是坚持这些选择,我真的很想知道你的经验。

哪种选择最适合你? 在通过 .bat运行 intelliJ 时,如何隐藏这个 cmd 窗口? :)

顺便说一下,这是 调谐智能的另一个链接。基本上,它说在 P. 20/21关闭窗口恢复和防病毒的系统目录。

另一种加速 intelliJ 的方法是将 intelliJ 系统文件夹放在 Ramdrive上(感谢 OlegYch | h)。

from idea.properties
idea.system.path=${idea.home}/.IntelliJIdea/system

参见 Win764位内存驱动器的超级用户这个。 1GB 对我来说不错。

另一个朋友给我的提示是 从防病毒程序中排除项目目录(扫描访问)

关于调优 Eclipse 也有类似的帖子:

68015 次浏览

The most useful thing you can do for IntelliJ is to have a lot of free memory for disk caching. IntelliJ saves alot of its processing work in cached files. This works well if you have plenty of free memory, but if your disk cache is limited, you will see regular, long lasting pauses.

I would suggest -XX:+UseConcMarkSweepGC rather than G1.

I also work local copies of files to minimise file access delay.

BTW: For the project I am on, I noticed the difference between working on a machine with 24 GB and one with 48 GB, even though the max heap is set to 2 GB ;)

Regarding:

How do I hide this cmd window while running intelliJ through the .bat?

Use the 'start' command and javaw.exe together, so, if you have:

SET JAVA_EXE=%IDEA_JDK%\jre\bin\java.exe
...
"%JAVA_EXE%" %JVM_ARGS% -cp "%CLASS_PATH%" %IDEA_MAIN_CLASS_NAME% %*

change it to:

SET JAVA_EXE=%IDEA_JDK%\jre\bin\javaw.exe
...
start "Intellij IDEA" /b "%JAVA_EXE%" %JVM_ARGS% -cp "%CLASS_PATH%" %IDEA_MAIN_CLASS_NAME% %*

For me switching to SSD-drive improved performance a lot (especially for large projects).

You can find good tips here. For example, the speed of switching from IDEA to another app and vice versa was significantly improved after turning the feature "Turn off Synchronize Files" off.

http://hamletdarcy.blogspot.com/2008/02/10-tips-to-increase-intellij-idea.html

I've done some experimenting, and found that to decrease GC pauses the following combination works best: -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50.

I'd also not make the heap too large, 512 or even smaller is OK for me. Otherwise when it becomes full the GC will have to walk it all which takes some time.

This combination works great on my Intellij13 running in Mavericks:

Updated Jul 18, 2017:

# custom IntelliJ IDEA VM options


-ea
-server
-Xms2G
-Xmx4096M
-Xss2m
-XX:MaxMetaspaceSize=2G
-XX:ReservedCodeCacheSize=1G
-XX:MetaspaceSize=512m
-XX:+UseConcMarkSweepGC
-XX:+DoEscapeAnalysis
-XX:SoftRefLRUPolicyMSPerMB=50
-XX:+UnlockExperimentalVMOptions
-Djava.net.preferIPv4Stack=true
-Dsun.io.useCanonCaches=false
-XX:LargePageSizeInBytes=256m
-XX:+UseCodeCacheFlushing
-XX:ParallelGCThreads=8
-XX:+DisableExplicitGC
-XX:+ExplicitGCInvokesConcurrent
-XX:+PrintGCDetails
-XX:+PrintFlagsFinal
-XX:+AggressiveOpts
-XX:+CMSClassUnloadingEnabled
-XX:CMSInitiatingOccupancyFraction=60
-XX:+CMSClassUnloadingEnabled
-XX:+CMSParallelRemarkEnabled
-XX:+UseAdaptiveGCBoundary
-XX:+UseSplitVerifier
-XX:CompileThreshold=10000
-XX:+OptimizeStringConcat
-XX:+UseStringCache
-XX:+UseFastAccessorMethods
-XX:+UnlockDiagnosticVMOptions
-XX:+HeapDumpOnOutOfMemoryError
-XX:+UseCompressedOops
-XX:-OmitStackTraceInFastThrow
-Dawt.useSystemAAFontSettings=lcd


-Dsun.java2d.renderer=sun.java2d.marlin.MarlinRenderingEngine

I keep this setting updated at https://github.com/adben/config/blob/master/idea64.vmoptions

Some time ago I was looking for the ways to speedup my project's compilation and that is result. This is not for IntelliJ IDEA itself but will help a lot when (re)building a big projects and, I guess, it will work with any other IDEs too. Also, I described Linux approach, but I'm sure Windows have it's own RAM-disk implementations.

The easiest way to speedup compilation is to move compilation output to RAM disk.

RAM disk setup

Open fstab

$ sudo gedit /etc/fstab

(instead of gedit you can use vi or whatever you like)

Set up RAM disk mount point

I'm using RAM disks in several places in my system, and one of them is /tmp, so I'll just put my compile output there:

tmpfs /var/tmp tmpfs defaults 0 0

In this case your filesystem size will not be bounded, but it's ok, my /tmp size right now is 73MB. But if you afraid that RAM disk size will become too big - you can limit it's size, e.g.:

tmpfs /var/tmp tmpfs defaults,size=512M 0 0

Project setup

In IntelliJ IDEA, open Project Structure (Ctrl+Alt+Shift+S by default), then go to Project - 'Project compiler output' and move it to RAM disk mount point:

/tmp/projectName/out

(I've added projectName folder in order to find it easily if I need to get there or will work with several projects at same time)

Then, go to Modules, and in all your modules go to Paths and select 'Inherit project compile output path' or, if you want to use custom compile output path, modify 'Output path' and 'Test output path' the way you did it to project compiler output before.

That's all, folks!

P.S. A few numbers: time of my current project compilation in different cases (approx):

HDD:     80s
SSD:     30s
SSD+RAM: 20s

P.P.S. If you use SSD disk, besides compilation speedup you will reduce write operations on your disk, so it will also help your SSD to live happily ever after ;)

Not sure why it has not been mentioned yet - you can enable Power Save mode, which turns off many IJ background activities, including Files Synchronization. Some articles says that it is possible to disable Files Sync in project structure options (like the article in answer by @OJ278), but I was not able to find this option in IJ 14, but Power Save mode seems to disable it.

I have a quite large code base (AOSP source code), so HD activity due to background files synchronization is annoying...

You can use the intellij's optimizer plugin:

https://zeroturnaround.com/free/optimizer-for-intellij-idea/

With the plugin you can:

  • Automatic tune virtual machine options
  • Disable class verification
  • Clean up system caches
  • Configure external build tools
  • Validate the latest Oracle JDK
  • Skip build and redeploy

I used this combination and it's working fine in my environment

-server
-Xms2048m
-Xmx2048m
-XX:NewSize=512m
-XX:MaxNewSize=512m
-XX:PermSize=512m
-XX:MaxPermSize=512m
-XX:+UseParNewGC
-XX:ParallelGCThreads=4
-XX:MaxTenuringThreshold=1
-XX:SurvivorRatio=8
-XX:+UseCodeCacheFlushing
-XX:+UseConcMarkSweepGC
-XX:+AggressiveOpts
-XX:+CMSClassUnloadingEnabled
-XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing
-XX:+CMSParallelRemarkEnabled
-XX:CMSInitiatingOccupancyFraction=65
-XX:+CMSScavengeBeforeRemark
-XX:+UseCMSInitiatingOccupancyOnly
-XX:ReservedCodeCacheSize=64m
-XX:-TraceClassUnloading
-ea
-Dsun.io.useCanonCaches=false

The answer provided by adben is very helpful for improving the performance in my machine. Though I slightly overrided it after reading a Dzone article,

-server
-Xms2g
-Xmx2g
-XX:NewRatio=3
-Xss16m
-XX:+UseConcMarkSweepGC
-XX:+CMSParallelRemarkEnabled
-XX:ConcGCThreads=4
-XX:ReservedCodeCacheSize=240m
-XX:+AlwaysPreTouch
-XX:+TieredCompilation
-XX:+UseCompressedOops
-XX:SoftRefLRUPolicyMSPerMB=50
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djsse.enableSNIExtension=false
-ea

They improved the performance of large projects by using the above configuration and works flawlessly for our projects too. Lastly, I disabled all the plugins I won't use and that improves the things as well.

Reference: https://dzone.com/articles/the-one-and-only-reason-to-customize-intellij-idea