- A Concurrent Affair - https://www.concurrentaffair.org -

DrJava Relapse

Today I figured I should go to the group meeting again, and once I got to the office and the lab, I started playing around with YourKit again. It’s just such a great tool. What I was trying to figure out was how we could profile while running the entire unit test suite. My intuition tells me that this might more accurately show us some bottlenecks, rather than randomly using it as an application.

I found out that I can choose the Java executable that Ant will use to launch itself by setting the JAVACMD environment variable. Unfortunately, forked JUnit tests in the task aren’t launched that way, and right now our DrJava unit tests only work in forked mode. So I let that issue drop. I didn’t want to relapsed into working on DrJava too much anyway.

But then I did. Because we received a bug report that I judged as critical: [ 1679178 ] 100% CPU use when compiling [1]. Under certain conditions — very reproducible, just had to use the attached project — the DrJava compiler would go into an infinite loop and consume all CPU power (of one core, at least).

I first used YourKit to diagnose the problem. There were an incredible number of calls to File.equals and String.indexOf… millions of them! That didn’t seem right. The culprit was the CompilerErrorModel._calculatePositions method: In a rare corner case, one that the original programmer had missed, the line number of the error received from javac would not match the line number information we had, in this case due to Windows/Unix line ending incompatibilities, and the error number was not incremented. Hence, the same error was processed infinitely.

I couldn’t really do anything about the wrong line endings, but at least I removed the infinite loop…

[2] [3]Share [4]