gkossakowski / Scalac Aspects
Labels
Projects that are alternatives of or similar to Scalac Aspects
scalac
using AspectJ.
Playground for instrumenting 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.
Examples
TraceSymbol.aj
)
Tracing where Symbols get created (This example implements the functionality @JamesIry tried to implement in scalac directly: https://github.com/scala/scala/pull/1756
To see it in action run
./scalac-aspects TraceSymbol.aj -DtraceSymbolIds=500,505 Foo.scala
PerUnitTiming.aj
)
Per-file timings (This example shows how to bring back -Dscala.timings
. See this discussion:
https://groups.google.com/d/topic/scala-internals/ZCToaWda7tQ/discussion
To see it in action run
./scalac-aspects PerUnitTiming.aj Foo.scala
TypeCompletionTiming.aj
)
Type completion timings (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
TypingTimings.aj
)
Typing timings (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:
https://gist.github.com/4543164
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.