加速 IntelliJ-Idea

发布于 2024-11-01 15:31:50 字数 2699 浏览 1 评论 0原文

我正在使用 intelliJ 进行 Scala 开发,上周获得了 8 GB 新 RAM,所以我想:是时候使用它了。我检查了我的任务管理器,发现 intelliJ 使用~250mb。从 eclipse 中我知道调整 JVM 选项对提高速度有很大帮助,所以我用 google 搜索...

并发现 这个适用于 OS X 我无法立即找到 JVM 选项,因此我开始调整 Xmx。 在 1 GB 时,我意识到它不再启动了。我检查了intelliJ java版本,发现它已经过时并且是32位的。

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

IntelliJ IDEA Community Edition 10.0.2\bin\idea.exe

to

IntelliJ IDEA Community Edition 10.0.2\bin\idea.BAT

并调整“Start in”。bat

会查找 JDK_HOME 并立即使用 64 位。

我当前的 VM 选项,位于

...\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:+UseParallelGC,您可以使用 -XX:+UseConcMarkSweepGC,即

桌面应用程序的公认选择, 但我已经改变了吞吐量 最近收藏家。因为有一个 快速的机器和足够小的堆, 您可以快速暂停,提高吞吐量 并且没有碎片问题 (ijuma。#scala)

更改:

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

我现在将坚持使用这些选项。我真的很想知道你的经验。

哪些选项最适合您? 通过 .bat 运行 intelliJ 时如何隐藏此 cmd 窗口? :)

顺便说一句,这是调整 intelliJ< 的另一个链接< /a>.基本上它在p.20/21上说要关闭系统目录的Windows恢复和防病毒功能。

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

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

请参阅Win 7 64 位 RAM 驱动器的超级用户这个。 1 GB 对我来说似乎还不错。

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

有关于调整 Eclipse 的类似帖子:

I'm using intelliJ for Scala development and got 8 GB of new RAM last week, so I thought: time to use it. I checked my task manager and found intelliJ using ~250mb. From eclipse I knew that tweaking JVM options helped a lot in improving speed, so I googled ...

and found this one for OS X
I couldn't find the JVM option immediately, so I started tweaking Xmx. At 1 GB, I realized it doesn't start any more. I checked the intelliJ java version, found it's outdated and 32bit.

So in order to use your current JDK and 64 bit you have to change your link to from:

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.

My current VM Options, which are located in

...\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

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)

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? :)

By the way, here's another link for tuning intelliJ. Basically it says on p.20/21 to turn off windows restore and antivirus for system dirs.

Another way to speed up intelliJ is to put intellij system folder on ramdrive (thanks OlegYch|h).

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

See Superuser for Win 7 64bit RAM Drive or this one.
1 GB seems fine for me.

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:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

憧憬巴黎街头的黎明 2024-11-08 15:31:50

这种组合在 Mavericks 中运行的 Intellij13 上效果很好:

更新于 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

我将此设置保持更新于 https://github.com/adben/config/blob/master/idea64.vmoptions

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

雅心素梦 2024-11-08 15:31:50

对我来说,改用 SSD 驱动器大大提高了性能(尤其是对于大型项目)。

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

浪推晚风 2024-11-08 15:31:50

前一段时间,我正在寻找加快项目编译速度的方法,这就是结果。这不适用于 IntelliJ IDEA 本身,但在(重新)构建大型项目时会很有帮助,而且我想它也适用于任何其他 IDE。另外,我描述了 Linux 方法,但我确信 Windows 有自己的 RAM 磁盘实现。

加速编译的最简单方法是将编译输出移至 RAM 磁盘。

RAM 磁盘设置

打开 fstab

$ sudo gedit /etc/fstab

(您可以使用 vi 或您喜欢的任何内容代替 gedit

设置 RAM 磁盘挂载点

我在系统中的多个位置使用 RAM 磁盘,其中之一是 /tmp,所以我将编译输出放在那里:

tmpfs /var/tmp tmpfs defaults 0 0

在这种情况下,您的文件系统大小将不受限制,但没关系,我的 /tmp现在的尺寸是73MB。但是如果您担心 RAM 磁盘大小会变得太大 - 您可以限制它的大小,例如:

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

项目设置

在 IntelliJ IDEA 中,打开项目结构(默认情况下Ctrl+Alt+Shift+S),然后转到项目 - '项目编译器输出'并将其移动到 RAM 磁盘安装点:(

/tmp/projectName/out

我添加了 projectName 文件夹,以便在我需要到达那里或要处理多个项目时轻松找到它同时)

然后,转到模块,在所有模块中,转到路径并选择“继承项目编译输出路径”,或者,如果您想使用自定义编译输出路径,请按照之前项目编译器输出的方式修改“输出路径”和“测试输出路径” 。

就这样,伙计们!

PS 几个数字:我当前项目在不同情况下编译的时间(大约):

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

PPS 如果你使用 SSD 磁盘,除了编译加速之外,你还会减少磁盘上的写入操作,因此也将帮助你的 SSD 从此幸福地生活; )

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 ;)

相权↑美人 2024-11-08 15:31:50

关于:

如何在通过 .bat 运行 intelliJ 时隐藏此 cmd 窗口?

将“start”命令和 javaw.exe 一起使用,因此,如果您有:

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

将其更改为:

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

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% %*
注定孤独终老 2024-11-08 15:31:50

您可以为 IntelliJ 做的最有用的事情就是拥有大量可用内存用于磁盘缓存。 IntelliJ 将大量处理工作保存在缓存文件中。如果您有足够的可用内存,这种方法效果很好,但如果您的磁盘缓存有限,您会看到定期的、长时间的暂停。

我建议使用 -XX:+UseConcMarkSweepGC 而不是 G1

我还处理文件的本地副本,以最大限度地减少文件访问延迟。

顺便说一句:对于我正在进行的项目,我注意到在 24 GB 的机器和 48 GB 的机器上工作之间存在差异,即使最大堆设置为 2 GB ;)

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 ;)

み格子的夏天 2024-11-08 15:31:50

我做了一些实验,发现要减少 GC 暂停,以下组合效果最好:-XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50

我也不会将堆设置得太大,512 甚至更小对我来说都可以。否则,当它变满时,GC 将不得不遍历所有内容,这需要一些时间。

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.

獨角戲 2024-11-08 15:31:50

您可以在这里找到好的提示。例如,关闭“关闭同步文件”功能后,从 IDEA 切换到另一个应用程序以及反之亦然的速度显着提高。

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

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

溇涏 2024-11-08 15:31:50

不知道为什么还没有提到 - 您可以启用省电模式,这会关闭许多IJ后台活动,包括文件同步。有些文章说可以在项目结构选项中禁用文件同步(例如@OJ278回答的文章),但我无法在IJ 14中找到此选项,但是省电模式似乎禁用了它。

我有一个相当大的代码库(AOSP源代码),因此由于后台文件同步而导致的高清活动很烦人......

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...

放手` 2024-11-08 15:31:50

adben 提供的答案对于提高我的机器的性能非常有帮助。虽然我在阅读 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

他们通过使用上述配置提高了大型项目的性能,并且也可以完美地用于我们的项目。最后,我禁用了所有我不会使用的插件,这也改善了情况。

参考:https://dzone.com/文章/定制 intellij-idea 的唯一原因

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

感悟人生的甜 2024-11-08 15:31:50

您可以使用 intellij 的优化器插件:

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

使用该插件,您可以:

  • 自动调整虚拟机选项
  • 禁用类验证
  • 清理系统缓存 配置
  • 外部构建工具
  • 验证最新的 Oracle JDK
  • 跳过构建并重新部署

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
等往事风中吹 2024-11-08 15:31:50

我使用了这个组合,它在我的环境中运行良好

-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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文