-
Notifications
You must be signed in to change notification settings - Fork 5
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
Optimize compilation phase for codec registration checker #135
Comments
This problem will likely be solved by replacing some |
Results from my compilation statistics for our phases (slightly different from PawelLipski's snippet): [info] dump-persistence-schema : 1 spans, ()2651.299ms (2.4%) And flamegraph generated by https://github.com/jvm-profiling-tools/async-profiler profiler on Hydra - in attachment. Potentially correlated fact is that:
So, it might be possible, that this long time is not caused by some lack of optimization inside SerializerCheckCompilerPluginComponent#newPhase (tried a lot of things to optimize it more, but failed to shorten it's duration). |
Wow, that's a non-trivial discovery indeed 🤔 |
Sorry, in my last comment I was wrong - SerializerCheckCompilerPluginComponent#newPhase gets invoked only one time and creates one instance of StdPhase type, but - underlying StdPhase#apply method gets invoked hundreds of times - e.g. 541 times (from my last test). |
Reopening as @LukaszKontowski's research is still ongoing |
With #155 managed to go down to 3,8% for the codec-registration-serializer-check phase. Now working on further improvement, which probably is possible by providing more optimization in the |
Small improvement for this phase in another PR: #158 (down from 3,8% to 3,5%) |
The heavy part of code that makes this phase slow is within https://github.com/VirtusLab/akka-serialization-helper/blob/main/codec-registration-checker-compiler-plugin/src/main/scala/org/virtuslab/ash/SerializerCheckCompilerPluginComponent.scala. In particular:
this _.toString from last line appears on lots of samples generated by the profiler (see attached snippet). However, it might be possible to further improve performance for this block code - if we could somehow narrow down the number of Types that we get from Trees here:
(sample collection returned by this Because for now this I also tried to narrow down Trees that we are checking by changing this line of code:
into something like this:
with known subclasses of Tree: but unfortunately failed to achieve better speed (and in most cases - it also did not work). However, I think that it still might be possible to further improve this and we can leave this issue alive - probably I failed for now because of small knowledge of the scala reflection internals. |
Helper comment for future attempts - in order to enable -Ystatistics flag on Hydra properly:
add following line to .settings
inside
|
Possibly working improvement - to be tested / checked / discussed etc. - for now it's just an idea that worked on one project and improved performance of the phase by 25% Replace
with
|
Time measurement of compilation phases on Hydra (commercial) project, with
-Ystatistics
flag:or just including the phases added by ash:
To be researched what specifically in
org.virtuslab.ash.SerializerCheckCompilerPluginComponent#newPhase
makes it so slow...probably b/c it checks for every combination of types discovered in the
@Serializer
-annotated class and the types detected in the precedingcodec-registration-class-sweep
phaseThe text was updated successfully, but these errors were encountered: