-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
chore: Simplify flight recorder interactions #32499
Conversation
"akka.actor.typed.internal.jfr.JFRActorFlightRecorder", | ||
NoOpActorFlightRecorder) | ||
} | ||
lazy val recorder: ActorFlightRecorder = new JFRActorFlightRecorder() |
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.
I think we can make the object the implementation instead of a separate singleton field, and then use that directly instead of a field in the classes that use it.
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.
More fields to skip, I expect all to be internal so should be fine to mima filter them if MiMa is unhappy about dropping constructor parameters etc.
@@ -274,7 +274,7 @@ private class ConsumerControllerImpl[A] private ( | |||
import ProducerControllerImpl.Resend | |||
import settings.flowControlWindow | |||
|
|||
private val flightRecorder = ActorFlightRecorder.recorder | |||
private val flightRecorder = ActorFlightRecorder |
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.
And no need for this field or the parameter above, use the ActorFlightRecorder directly
@@ -448,7 +448,7 @@ private[akka] class Shard( | |||
|
|||
private val rememberEntities: Boolean = rememberEntitiesProvider.isDefined | |||
|
|||
private val flightRecorder = ShardingFlightRecorder.recorder | |||
private val flightRecorder = ShardingFlightRecorder |
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.
Use directly instead
@@ -284,7 +284,7 @@ private[remote] abstract class ArteryTransport(_system: ExtendedActorSystem, _pr | |||
|
|||
override val log: MarkerLoggingAdapter = Logging.withMarker(system, classOf[ArteryTransport]) | |||
|
|||
val flightRecorder: RemotingFlightRecorder = RemotingFlightRecorder.recorder | |||
private val flightRecorder = RemotingFlightRecorder |
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.
drop field, and also the debug log statement below, it's there to know which recorder was used but now there is only one
@@ -150,7 +150,7 @@ private[remote] class Association( | |||
require(remoteAddress.port.nonEmpty) | |||
|
|||
private val log = Logging.withMarker(transport.system, classOf[Association]) | |||
private def flightRecorder = transport.flightRecorder | |||
private def flightRecorder = RemotingFlightRecorder |
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.
use directly
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.
remove this def
altogether?
Dang it, meant to comment, not to approve |
# Some modules (remoting only right now) can emit custom events to the Java Flight Recorder if running | ||
# on JDK 11 or later. If you for some reason do not want that, it can be disabled and switched to no-ops | ||
# with this toggle. | ||
java-flight-recorder { |
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.
This should probably be mentioned in the release-notes MD?
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.
Yes, not a big problem but we should still mention
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.
Ok, going to rebase on top of the merged #32497.
akka-remote/src/test/scala-jdk9-only/akka/remote/artery/jfr/RemotingFlightRecorderSpec.scala
Outdated
Show resolved
Hide resolved
544e8b0
to
8f498a1
Compare
.../main/resources/META-INF/native-image/com.typesafe.akka/akka-actor-typed/reflect-config.json
Outdated
Show resolved
Hide resolved
.../resources/META-INF/native-image/com.typesafe.akka/akka-cluster-sharding/reflect-config.json
Outdated
Show resolved
Hide resolved
...e/src/main/resources/META-INF/native-image/com.typesafe.akka/akka-remote/reflect-config.json
Outdated
Show resolved
Hide resolved
akka-cluster-sharding/src/test/scala/akka/cluster/sharding/NativeImageMetadataSpec.scala
Outdated
Show resolved
Hide resolved
akka-cluster-sharding/src/test/scala/akka/cluster/sharding/NativeImageMetadataSpec.scala
Outdated
Show resolved
Hide resolved
akka-remote/src/test/scala/akka/remote/NativeImageMetadataSpec.scala
Outdated
Show resolved
Hide resolved
akka-actor-typed-tests/src/test/scala/akka/actor/typed/NativeImageMetadataSpec.scala
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,8 @@ | |||
# #32499 chore: Simplify flight recorder interactions |
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.
The file name should be the latest release. Did this solve anything? Is it needed?
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.
I changed the name 👍
Did this solve anything? Is it needed?
When I remove the content of the file, I get this error:
sbt:akka-actor> mimaReportBinaryIssues
[error] akka-actor: Failed binary compatibility check against com.typesafe.akka:akka-actor_2.13:2.6.7! Found 2 potential problems (filtered 112)
[error] * class akka.util.FlightRecorderLoader does not have a correspondent in current version
[error] filter with: ProblemFilters.exclude[MissingClassProblem]("akka.util.FlightRecorderLoader")
[error] * object akka.util.FlightRecorderLoader does not have a correspondent in current version
[error] filter with: ProblemFilters.exclude[MissingClassProblem]("akka.util.FlightRecorderLoader$")
[error] stack trace is suppressed; run last mimaReportBinaryIssues for the full output
[error] (mimaReportBinaryIssues) Failed binary compatibility check against com.typesafe.akka:akka-actor_2.13:2.6.7! Found 2 potential problems (filtered 112)
[error] Total time: 0 s, completed Sep 4, 2024, 9:44:43 AM
sbt:akka-actor>
@@ -0,0 +1,3 @@ | |||
# #32499 chore: Simplify flight recorder interactions |
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.
same here
new TcpOutboundConnected(remoteAddress, streamName).commit() | ||
|
||
def tcpOutboundSent(size: Int): Unit = | ||
new TcpOutboundSent(size).commit() |
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.
Do we have to verify that it works as we expect? That this isn't adding any overhead when JFR isn't used? We had a description somewhere of how the jvm would omit this execution, but can't find it. I assume there wouldn't even be allocations of the events that could increase pressure on GC?
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.
Yeah, I have the same recollection. It should be escape analysed to zero allocation when enabled, but then also completely eliminated when JFR is disabled. I also don't have any reference though, so we should double check by running a benchmark with JFR disabled and look compare allocations (can't use JFR obviously :D)
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.
maybe jmh with -prof gc
would be sufficient
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.
Yeah, my thinking, before and after this change to compare allocation rate, maybe the CodecBenchmark
I think that involves some of the remoting stream stages?
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.
I'll do some verification bench runs today
b29d0e5
to
67238d7
Compare
@@ -0,0 +1,8 @@ | |||
# #32499 chore: Simplify flight recorder interactions |
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.
2.9.5, not 2.9.5.0
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.
🤦
Bench results looks good, I think the differences between main and this branch in my results is small enough to be just noise, and the normalised allocation rate looks the same (I expect it should be allocating noticeably more per op if our assumptions were true) Raw output from runs and details: |
Is the CodecBenchmark using RemotingFlightRecorder? I don't see that Encoder or Decoder stages are using it. |
18ecb1e
to
6380119
Compare
The |
New bench run, you can see bench details here https://github.com/akka/akka/compare/wip-jfr-simplify-bench?expand=1#diff-5716ff6ab54d9a1887ab449af41b3f2b185e83cb6a22bc8d5c3580b4cdf4bb00R1 , it basically compares alloc rate for incrementing a counter to 10 with counting to 10 calling RemotingFlightRecorder for every increment. Result seems to confirm that those calls are thrown out by JIT:
|
6380119
to
b327f21
Compare
b327f21
to
ae360a1
Compare
thanks for the new bench |
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.
LGTM
chore: Simplify flight recorder interactions. Fixes #32309
akka.java-flight-recorder.enabled
, to always recorder Flight Recorder interactions.-XX:+UnlockCommercialFeatures -XX:+FlightRecorder
handle any further usage.