Code Monkey home page Code Monkey logo

scalac-aspects's Introduction

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.

Examples

Tracing where Symbols get created (TraceSymbol.aj)

This example implements the functionality @JamesIry tried to implement in scalac directly: scala/scala#1756

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: https://groups.google.com/d/topic/scala-internals/ZCToaWda7tQ/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:

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.

scalac-aspects's People

Contributors

fanf avatar gkossakowski avatar lrytz avatar paulp avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.