Skip to content
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 codec-registration-serializer-check phase #155

Merged
merged 2 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ Then, in the target project sbt shell, type `compile`. If the compilation finish
Remember to type `clean` after successful compilations.
Otherwise, incremental compilation might determine there is nothing to compile and won't run the plugin you are testing.

### Profiling

To profile akka-serialization-helper compiler plugin used in another project - follow instructions from https://www.lightbend.com/blog/profiling-jvm-applications
You might as well use any other profiler, but using https://github.com/jvm-profiling-tools/async-profiler with flamegraphs should be really effective and easy to achieve (+ no unexpected bugs / issues / errors).

### Code quality

Before committing, don't forget to type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ class SerializerCheckCompilerPluginComponent(
private var typesNotDumped = true
private val typesToCheck = mutable.Map[String, List[(String, String)]]().withDefaultValue(Nil)

override def newPhase(prev: Phase): Phase =
private lazy val ft = classSweep.foundTypes.toSet
private lazy val tu = classSweep.typesToUpdate.toSet

override def newPhase(prev: Phase): Phase = {
new StdPhase(prev) {
override def apply(unit: global.CompilationUnit): Unit = {
if (typesNotDumped) {
Expand All @@ -44,8 +47,6 @@ class SerializerCheckCompilerPluginComponent(
val buffer = ByteBuffer.allocate(channel.size().toInt)
channel.read(buffer)
val ot = CodecRegistrationCheckerCompilerPlugin.parseCacheFile(buffer.rewind()).toSet
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh TBH I don't like C++-style identifiers like that... esp. in a code like this, which already puts a heavy mental burden on the readers ☹️ pls reasonably expand the identifiers while you're here!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PawelLipski - done - please, take a look

val ft = classSweep.foundTypes.toSet
val tu = classSweep.typesToUpdate.toSet
val out = ((ot -- tu) | ft).toList

val outData = out.map(x => x._1 + "," + x._2).sorted.reduceOption(_ + "\n" + _).getOrElse("")
Expand Down Expand Up @@ -112,6 +113,7 @@ class SerializerCheckCompilerPluginComponent(
.collect {
case x: Tree if x.tpe != null => x.tpe
}
.distinct
.groupBy(_.toString())
.filter(_._1.matches(filterRegex))
.map(_._2.head)
Expand All @@ -130,6 +132,7 @@ class SerializerCheckCompilerPluginComponent(
else
typeArgsBfs(next, acc)
}

val foundInSerializerTypesFqcns = typeArgsBfs(foundTypes.toSet).map(_.typeSymbol.fullName)

val missingFqcn = typesToCheck(fqcn).map(_._2).filterNot(foundInSerializerTypesFqcns)
Expand Down Expand Up @@ -165,4 +168,5 @@ class SerializerCheckCompilerPluginComponent(
}
}
}
}
}