Scala project occupies more than 100% CPU time

Whenever I open the scala project, the cpu consumption always goes up over 100%. Not in the loading time or indexing time, but while I am doing nothing. only open JAVA projects are normal. Is it Scala plugin issue?

0
17 comments
Avatar
Permanently deleted user

I concur - for me it's started happening after the latest plugin update. Code analysis seems stuck at between 20-30% and takes cpu over 100% (for the last 10mins). Have put code analysis in power save mode to disable it.

EDIT - I removed and then re-installed the scala plugin and that seems to have fixed it for me.

0

Hello, could you provide a snapshot (http://devnet.jetbrains.com/docs/DOC-192) ?

0
Avatar
Permanently deleted user

Unfortunately I can't - I didn't take any stats before re-installing the plugin. It's been working fine since the reinstall. So for me, and unless many others start noticing issues; I'm happy to consider it something local to my env which got cleaned up with the plugin reinstall.

Perhaps yang sun can offer a snapshot

0
Avatar
Permanently deleted user

Here's my CPU snapshot.



Attachment(s):
IU-129.713_yangsun_16.09.2013_11.50.18.zip
0
Avatar
Permanently deleted user

I debug it a little. It appears that Slick has something to do with the big CPU usage. Whenever I create an object extends App, and add a few objects extends Table in the same file, and then add some code in the App object, the CPU usage goes up over 100%. (Only when the xxx.scala file is opened in intellij and in the front). If I separate the Table objects and App object in two files, it seems OK.

0
Avatar
Permanently deleted user

I finally identified which line cause the problem. Whenever I have this line:

def autoInc = id.? ~ channel_type ~ auth <>(Channel, Channel.unapply _) returning id

CPU will run over 100% like crazy. If I comment it out, CPU runs normally.

Any idea why?

BTW, the line of code is in a Table definition using Slick.

0

Can you give me example project which causes this performance problem?

Best regards,
Alexander Podkhalyuzin.

0
Avatar
Permanently deleted user

I tried to recreate the problem on my Macbook Pro.  just created an empty scala project and added "slick_2.10-1.0.1-RC1.jar" to the project Library. And then created Test.scala with the following code:

import scala.slick.driver.MySQLDriver.simple._

case class Test(id:Option[Int], name:String)


object Tests extends Table[Test]("test"){
  def id = column[Int]("id", O.AutoInc, O.PrimaryKey)
  def name = column[String]("name")
  def * = id.? ~ name <> (Test, Test.unapply _) returning id
}


Once I remove the "returning id", CPU consumption reduces to normal. I tried with H2Driver as well. As long as I have the returning(id) in the code, the CPU consumption is over 100%.
0

I can confirm this, always when I open a Scala file with Intellj my computer gets loud and starts overheating - once I watch activity monitor and CPU (consumed by IntelliJ) was 110% (!!). It doesn't happen with other files (HTML, Css, JS, Java).

My specs: MacBook Pro 2.7 Ghz Intel Core i7 with 8 GB Ram.

Mayor lag specially typing, when hold key e.g. /////////////////////////////////////////////////////// to make a separator it blocks completly and I have to wait 5-10 seconds until I can type again.

I have no time to debug this, to see what code exactly is responsible. One file It's a quite simple controller object for play framework. I don't have "returning" anywhere in my code.

0

Hi,

I investigated this problem a bit and could find (one of?) the lines causing lag:

  def foo(url:String):List[String] = {

    val parts = ListBuffer[String]()
    val r = """^(?:https|http)?(?:://)?(?:www\.)?([^/]+)([^\?]*)?(.*)?""".r
    val r(a, b, c) = url
    val x = a.split(":")(0) //<-- this line
    parts.toList
  }

There was a clear difference, when this line is enabled CPU is 100+%, otherwise 12%

There complete file:

package controllers

import play.api.mvc.Controller
import play.modules.reactivemongo.MongoController
import scala.collection.mutable.ListBuffer

object Bar extends Controller with MongoController {

  def foo(url:String):List[String] = {

    val parts = ListBuffer[String]()
    val r = """^(?:https|http)?(?:://)?(?:www\.)?([^/]+)([^\?]*)?(.*)?""".r
    val r(a, b, c) = url
    val x = a.split(":")(0) //<-- this line
    parts.toList
  }

}

Hope that this helps.

0

Any updates on this? It's really annoying to use the IDE like this... I can check my emails or drink my tea each time I type 2 words... I disabled auto build, put highlighting level for the file to "None" (but nothing seems to happen, it continues highlighting normally) and disabled Scala type-aware highlighting (also continues highlighting). Problem persists.

In my original file (which is long - I reduced it to the posted file deleting randomly code and checking if there's lag) the problem is not only the line I posted, there also seem to be other code, since if I comment this line there, there's still lag. I don't have time to find each of these problem lines though.

Forgot to mention: I'm using IDEA 12.1.6, Plugin version 0.22.302

0

I'm working on performance issues right now. And I'm fixing performance of "for statements", in some cases it's completely unusable. I hope I'll do it today, then I'll continue with other performance issues.
As for your issue please attach CPU snapshot (http://devnet.jetbrains.com/docs/DOC-192). Your problem is probably known and has workaround.

Best regards,
Alexander Podkhalyuzin.

0

I just check your code example and for me it works ok.
Please give me CPU snapshot to understand what's going on. Thank you!

Best regards,
Alexander Podkhalyuzin.

0

Ok, snapshot attached. I just pasted the code sample I posted in an empty file and let "/" pressed a while until not responsive. Activity monitor was reporting 104% CPU. There I took the snapshot.

P.S. Sorry for ignoring your message before, for some reason I didn't see it.



Attachment(s):
idea-2013-10-11-2.snapshot.zip
0

Ok, looks like you have enabled language injection in Scala. Just disable it and performance will become normal.

Best regards,
Alexander Podkhalyuzin.

0

I disabled all checkboxes in preferences -> Language injections (and I also selected in "Advanced" "No runtime instrumentation" and "Do not analyze anything (fast)", in the case it helps).

I'm still having the same performance problems.

0

We have setting for Scala: Settings -> Scala -> Other settings -> Disable language injection in Scala files.
If it doesn't help either, please send me another snapshot of freesing (you also can try other performance related settings).

Best regards,
Alexander Podkhalyuzin.

0

Please sign in to leave a comment.