-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[Kapt] Support dumping processors stats to a file #4280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…apt-dump-processor-timings
private fun dumpProcessorTiming(wrappedProcessors: List |
||
logger("Dumping Kapt Annotation Processing performance report to ${apReportFile?.absolutePath}") | ||
|
||
apReportFile?.writeBytes(buildString { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File.writeText maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
Note that I did it this way because that's how -Xdump-perf works (see code)
@@ -142,6 +144,17 @@ private fun showProcessorTimings(wrappedProcessors: List |
|||
} | |||
} | |||
|
|||
private fun dumpProcessorTiming(wrappedProcessors: List |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apReportFile can be non-nullable here, because you already check it's nullability in ?.let about
Hey @zveznicht, any other feedback on these changes? |
There are some failing integration tests, I'll into them later this week or next week |
OK thanks for the update @zveznicht. Please let me know if I can help speed up the process. Meanwhile, I'd like to generate modified jars with these changes for us to use. When I use the gradle "jar" task, the jars I'm getting are twice in size when compared to the original jars. Are you using the same gradle task to generate the jars you're shipping, or do you have some other process? For more context, I'm generating the following jars: I created these jars for both kotlin 1.4.21 and 1.4.32 by checking out the version's tag (v1.4.21-2 and v1.4.32, respectively) and then running the "jar" gradle task from within each module. I did this from IntelliJ and command line, in both cases the jar I'm getting is much bigger than the one that you ship with the kotlin distribution. I was thinking maybe you have a different method to do this. |
I believe by default jars doesn't get compressed. You can try to build with |
Changes were commited to master in b8002cb |
…sor-timings option Summary: These modified Kapt library jars add support for a new parameter -Kapt-dump-processor-timings (or -P plugin:org.jetbrains.kotlin.kapt3:dumpProcessorTimings) for dumping performance stats of Annotation Processors into a file. In the next diffs, we'll use the new option in Buck to get the Annotation Processing perf stats and report them to Scuba. The modified jars were generated from our forked Kotlin repo, with the changes added in D28120848. Note: This change was upstreamed to Kotlin's repository ([Pull Request](JetBrains/kotlin#4280)) and will be available as part of the public release of Kotlin 1.5. ---------------------------------------------------------------------------- For future reference - in case we would need to generate jars for new Kotlin versions (until Kotlin 1.5 comes out), here's how to generate new jars: Make sure our Kotlin fork repository is upgraded to the new Kotlin version (e.g. 1.4.99) As part of the upgrade, all existing patches should be re-applied (see [wiki](https://www.internalfb.com/intern/wiki/Kotlin/Kotlin_IDE_Plugin_Development/#source-code-upgrade)) Generate the jars ```cd./gradlew :kotlin-annotation-processing:jar :kotlin-annotation-processing-runtime:jar :kotlin-annotation-processing-cli:jar -Pteamcity=true ``` Get the generated jars ```cp plugins/kapt3/kapt3-cli/build/libs/kotlin-annotation-processing-cli*.jar ~/tmp/kotlin-annotation-processing-cli.jar cp plugins/kapt3/kapt3-compiler/build/libs/kotlin-annotation-processing*.jar ~/tmp/kotlin-annotation-processing.jar cp plugins/kapt3/kapt3-runtime/build/libs/kotlin-annotation-processing-runtime*.jar ~/tmp/kotlin-annotation-processing-runtime.jar ``` Copy jars to ```fbsource/third-parth/kotlin/ /lib/``` and ```xplat/build_infra/buck_client/test/com/facebook/buck/toolchains/kotlin/kotlinc/libexec/lib/kotlin-annotation-processing.jar``` Create diffs Reviewed By: amnn fbshipit-source-id: 1a3baea7ac0d5d2b5f0a845357257a3bbcc65602
Summary: Adds support for Buck to read Annotation Processing performance report files, generated by Kotlin's Kapt plugin. This new step would run after compiling a Kotlin rule, parse the generated report file and send the data to be stored elsewhere using Buck's event bus. Note: requires a new Kapt option that was added in this [Pull Request](JetBrains/kotlin#4280). Example for a stats report: ```Kapt Annotation Processing performance report: com.udinic.MetagenProcessor: total: 1650 ms, init: 39 ms, 3 round(s): 1611 ms, 0 ms, 0 ms com.udinic.ComponentsProcessor: total: 11 ms, init: 11 ms, 0 round(s): com.udinic.InjectorProcessor: total: 390 ms, init: 17 ms, 3 round(s): 293 ms, 47 ms, 33 ms ``` Reviewed By: IanChilds fbshipit-source-id: fd31009eb6823c53347d43da044b21f3781c1f55
There's already an option to print stats on the Annotation Processors execution, using the -Kapt-show-processor-timings plugin option. This PR adds a way to dump that report into a file, using a new plugin option -Kapt-dump-processor-timings (or org.jetbrains.kotlin.kapt3:dumpProcessorTimings).
Example for such report:
This is similar to the kotlinc options
-Xreport-perf
and-Xdump-perf
, which are also providing a performance report printed to the log or dumped into a file, respectively.I tested my changes in command line, by generating a new Kapt jar with these changes and then using it in a sample project that has Annotation Processors. Example command:
This command will run kapt and dump the stats to the file "cli-tests/ap-perf-report.file"