Speeding Up Compilation Time with scalac-profiling


#1

Hello everyone,

I recently posted in scala-lang about how we can use scalac-profiling to profile and speed up compilation times of projects using a lot of macros or implicit searches.

Read the blog post here.

If you have any question about the analysis or the plugin, I’m happy to answer them in this thread.

Happy profiling!


#2

This is very good. Quite a long read. I will definitely use it once I clear my schedule a little to do performance tweaks.


#3

…once I clear my schedule a little to read it…


#4

Hi! Thank you for the blog post! It’s really interesting and useful. I’m following the instructions, but I can’t understand how to generate a Flamegraph. Whenever I execute the script:

./flamegraph.pl \
--hash --countname="ns" \
--color=scala-compilation \
$MY_PATH_TO_FLAMEGRAPH_DATA > bloop-profile-initial.svg

I get this error message: ERROR: No stack counts found.
I went through the Flamegraph README file, but still, I’m not sure what I’m missing there…


#5

Hey :wave: Did you make sure that the flamegraph file is not empty and that you replace $MY_PATH_TO_FLAMEGRAPH_DATA with the absolute path to the flame graph file? Also, did you confirm you are using the flame graph script from the submodule in the scalac-profiling repo?


#6

Oh yes, the flamegraph file is empty, but it shouldn’t be, right? :thinking: I’ve run sbt clean compile with these scalacOptions
"-Ycache-plugin-class-loader:last-modified",
"-Xplugin:$MY_PATH_TO_PLUGIN_JAR",
"-P:scalac-profiling:no-profiledb",
"-P:scalac-profiling:show-profiles",
"-P:scalac-profiling:sourceroot:$MY_PROJECT_BASE_PATH"
And I’m using the flame graph script from the submodule in the scalac-profiling repo.


#7

Can you show me the scalac options that have the variables starting with $ replaced by the values? It’s not clear to me if you’re resolving the plugin first and then using the returned path in -Xplugin for example.

Another important thing (and this is sbt specific) is that you may not be adding the scalac options correctly to your build. If you want to profile the compile time of the application, make sure > show $YOUR_PROJECT/compile:scalacOptions contains the options you add, if you’re profiling the tests, use show $YOUR_PROJECT/test:scalacOptions.


#8

As someone who just went through the agony of finding out why it didn’t accept my flamegraph, check the newlines. It doesn’t work with windows newlines.