简体   繁体   English

加速IntelliJ-Idea

[英]Speedup IntelliJ-Idea

I'm using intelliJ for Scala development and got 8 GB of new RAM last week, so I thought: time to use it. 我正在使用intelliJ进行Scala开发并且上周获得了8 GB的新RAM,所以我想:时间使用它。 I checked my task manager and found intelliJ using ~250mb . 我检查了我的任务管理器,发现了使用~250mb的intelliJ From eclipse I knew that tweaking JVM options helped a lot in improving speed, so I googled ... 从eclipse我知道调整JVM选项对提高速度有很大帮助,所以我用谷歌搜索...

and found this one for OS X I couldn't find the JVM option immediately, so I started tweaking Xmx. 并发现这个OS X我无法立即找到JVM选项,所以我开始调整Xmx。 At 1 GB, I realized it doesn't start any more. 在1 GB时,我意识到它不再启动了。 I checked the intelliJ java version, found it's outdated and 32bit. 我检查了intelliJ java版本,发现它已经过时了,32位。

So in order to use your current JDK and 64 bit you have to change your link to from: 因此,为了使用您当前的JDK和64位,您必须将链接更改为:

IntelliJ IDEA Community Edition 10.0.2\bin\idea.exe

to

IntelliJ IDEA Community Edition 10.0.2\bin\idea.BAT

and adjust "Start in" 并调整“开始”

The bat looks for JDK_HOME and uses 64bit now. 蝙蝠寻找JDK_HOME并现在使用64位。

My current VM Options , which are located in 我当前的VM选项 ,位于

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

are

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

Instead of -XX:+UseParallelGC , you can use -XX:+UseConcMarkSweepGC , which is 而不是-XX:+UseParallelGC ,你可以使用-XX:+UseConcMarkSweepGC ,这是

the accepted choice for desktop apps, but I have changed to the throughput collector recently. 桌面应用程序的可接受选择,但我最近更改为吞吐量收集器。 because with a fast machine and a small enough heap, you have quick pauses, more throughput and no issues with fragmentation (ijuma. #scala) 因为有一个快速的机器和一个足够小的堆,你有快速暂停,更多的吞吐量和没有碎片问题(ijuma。#sclala)

Changes: 变化:

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

I'll stick to these options for now. 我现在会坚持这些选择。 I would really like to know your experience with it. 我真的很想知道你的经历。

Which options work best for you? 哪种选择最适合您? How do I hide this cmd window while running intelliJ through the .bat ? 如何通过.bat运行intelliJ时隐藏此cmd窗口? :) :)

By the way, here's another link for tuning intelliJ . 顺便说一句,这是调整intelliJ的另一个链接。 Basically it says on p.20/21 to turn off windows restore and antivirus for system dirs. 基本上它在p.20 / 21上说关闭Windows恢复和系统目录的防病毒。

Another way to speed up intelliJ is to put intellij system folder on ramdrive (thanks OlegYch|h). 加快的IntelliJ另一种方法是把在RAMDRIVE的IntelliJ系统文件夹(感谢OlegYch | H)。

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

See Superuser for Win 7 64bit RAM Drive or this one . 请参阅Win 7 64位RAM驱动器的超级用户 超级用户 1 GB seems fine for me. 1 GB对我来说似乎没问题。

Another hint a friend gave me is to exclude the project directories from your antivirus (scan on access) 朋友给我的另一个提示是从防病毒软件中排除项目目录 (扫描访问时)

There are similar posts regarding tuning Eclipse: 调整Eclipse有类似的帖子:

This combination works great on my Intellij13 running in Mavericks: 这个组合对我在小牛队中运行的Intellij13很有用:

Updated Jul 18, 2017 : 2017年7月18日更新

# 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 我将此设置更新为https://github.com/adben/config/blob/master/idea64.vmoptions

对我来说,切换到SSD驱动器可以提高性能(特别是对于大型项目)。

Regarding: 关于:

How do I hide this cmd window while running intelliJ through the .bat? 如何通过.bat运行intelliJ时隐藏此cmd窗口?

Use the 'start' command and javaw.exe together, so, if you have: 同时使用'start'命令和javaw.exe,如果你有:

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% %*

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. 这不适用于IntelliJ IDEA本身,但在(重新)构建大型项目时会有很多帮助,我想,它也适用于任何其他IDE。 Also, I described Linux approach, but I'm sure Windows have it's own RAM-disk implementations. 另外,我描述了Linux方法,但我确信Windows拥有自己的RAM磁盘实现。

The easiest way to speedup compilation is to move compilation output to RAM disk. 加速编译的最简单方法是将编译输出移动到RAM磁盘。

RAM disk setup RAM磁盘设置

Open fstab 打开fstab

$ sudo gedit /etc/fstab

(instead of gedit you can use vi or whatever you like) (而不是gedit你可以使用vi或任何你喜欢的)

Set up RAM disk mount point 设置RAM磁盘挂载点

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: 我在我的系统中的几个地方使用RAM磁盘,其中一个是/tmp ,所以我只是将我的编译输出放在那里:

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. 在这种情况下,你的文件系统大小不会受限制,但没关系,我现在的/tmp大小是73MB。 But if you afraid that RAM disk size will become too big - you can limit it's size, eg: 但如果你担心RAM磁盘大小会变得太大 - 你可以限制它的大小,例如:

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: 在IntelliJ IDEA中,打开项目结构(默认为Ctrl+Alt+Shift+S ),然后转到项目 - '项目编译器输出'并将其移动到RAM磁盘安装点:

/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) (我已经添加了projectName文件夹,以便在需要到达时可以轻松找到它或者同时使用多个项目)

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! 总而言之,伙计们!

PS A few numbers: time of my current project compilation in different cases (approx): PS一些数字:我在不同情况下当前项目编译的时间(约):

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

PPS 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 ;) PPS如果您使用SSD磁盘,除了编译加速,您将减少磁盘上的写入操作,因此它也将帮助您的SSD永远幸福地生活;)

The most useful thing you can do for IntelliJ is to have a lot of free memory for disk caching . 您可以为IntelliJ做的最有用的事情是为磁盘缓存提供大量可用内存 IntelliJ saves alot of its processing work in cached files. IntelliJ在缓存文件中保存了很多处理工作。 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 . 我建议-XX:+UseConcMarkSweepGC而不是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 ;) 顺便说一句 :对于我所在的项目,我注意到使用24 GB的机器和48 GB的机器之间的区别,即使最大堆设置为2 GB;)

I've done some experimenting, and found that to decrease GC pauses the following combination works best: -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50. 我做了一些实验,发现为了减少GC暂停,以下组合效果最好:-XX:+ UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB = 50。

I'd also not make the heap too large, 512 or even smaller is OK for me. 我也不会让堆太大,512甚至更小对我来说都没问题。 Otherwise when it becomes full the GC will have to walk it all which takes some time. 否则,当它变满时,GC必须全部耗尽,这需要一些时间。

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. 例如,关闭“关闭同步文件”功能后,从IDEA切换到另一个应用程序的速度显着提高。

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

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 . 不知道为什么还没有提到它 - 你可以启用Power Save mode ,这会关闭许多IJ后台活动,包括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. 有些文章说可以在项目结构选项中禁用Files Sync(如@ OJ278中的文章),但我无法在IJ 14中找到此选项,但Power Save mode似乎禁用它。

I have a quite large code base ( AOSP source code), so HD activity due to background files synchronization is annoying... 我有一个相当大的代码库( AOSP源代码),所以由于后台文件同步导致的HD活动很烦人...

You can use the intellij's optimizer plugin: 您可以使用intellij的优化器插件:

https://zeroturnaround.com/free/optimizer-for-intellij-idea/ 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 验证最新的Oracle JDK
  • Skip build and redeploy 跳过构建和重新部署

The answer provided by adben is very helpful for improving the performance in my machine. adben提供的答案对于提高我的机器性能非常有帮助。 Though I slightly overrided it after reading a Dzone article, 虽然在阅读Dzone文章后我略微凌驾一堂,

-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 参考: https//dzone.com/articles/the-one-and-only-reason-to-customize-intellij-idea

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM