Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Playground for instrumenting scalac using AspectJ.

Exploration of the idea of instrumenting scalac with AspectJ. There are two main use cases for instrumentation of scalac:

  • debugging
  • profiling

Examples below focus mostly on profiling scalac. They help with identifying source files or even single lines causing unusually slow compilation times.

If your Scala code compiles slower than 500-600LoC/s then you might find this tool useful. You can count lines of code in your project with cloc.


Tracing where Symbols get created (TraceSymbol.aj)

This example implements the functionality @JamesIry tried to implement in scalac directly:

To see it in action run

./scalac-aspects TraceSymbol.aj -DtraceSymbolIds=500,505 Foo.scala

Per-file timings (PerUnitTiming.aj)

This example shows how to bring back -Dscala.timings. See this discussion:

To see it in action run

./scalac-aspects PerUnitTiming.aj Foo.scala

Type completion timings (TypeCompletionTiming.aj)

This example shows how to measure how much time is spent on calculating given type. The cool thing about it is that it also shows position in a file where given type is referred.

Too see it in action run

./scalac-aspects TypeCompletionTiming.aj Foo.scala

The cool thing is that scalac options work as expected. Try:

./scalac-aspects TypeCompletionTiming.aj -Yshow-symkinds Foo.scala

Typing timings (TypingTimings.aj)

The TypingTimings.aj has strictly more functionality (it collects more information) than the TypeCompletionTiming.aj but it's not an example of the best code.

I include it because it's powerful enough to discover real problem with compilation times. I used it for compiling Scala library and I discovered that some types take 0.25s to compute. If you are wondering, that'ts a lot.

Too see it in action run

./scalac-aspects TypingTimings.aj Foo.scala

Also, check out the little tool I created for post-processing data printed by this tool:

Maven support

François Armand (@fanf) has a blog post showing how to use aspects mentioned above with Maven projects.

Scala versions supported

This project has been tested with Scala 2.10 and 2.11 compilers.


Playground for instrumenting `scalac` using AspectJ.



No releases published


No packages published

Contributors 4

You can’t perform that action at this time.