You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "mdedetrich (via GitHub)" <gi...@apache.org> on 2023/05/04 17:27:20 UTC

[GitHub] [incubator-pekko] mdedetrich commented on a diff in pull request #305: Enable inliner for Scala 2

mdedetrich commented on code in PR #305:
URL: https://github.com/apache/incubator-pekko/pull/305#discussion_r1185305997


##########
project/PekkoInlinePlugin.scala:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * license agreements; and to You under the Apache License, version 2.0:
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * This file is part of the Apache Pekko project, derived from Akka.
+ */
+
+import sbt.Keys._
+import sbt._
+import sbt.plugins.JvmPlugin
+
+object PekkoInlinePlugin extends AutoPlugin {
+  override def trigger: PluginTrigger = allRequirements
+
+  override def requires: Plugins = JvmPlugin
+
+  val enabled = !sys.props.contains("pekko.no.inline")
+
+  private val flagsFor212 = Seq(
+    "-opt-inline-from:org.apache.pekko.**",
+    "-opt:l:inline")
+
+  private val flagsFor213 = Seq(
+    "-opt-inline-from:org.apache.pekko.**",

Review Comment:
   So one thing to be aware of is that `<sources>` only works with the sources within an sbt project, i.e.
   
   > `-opt:inline:<sources>`, where the pattern is the literal string `<sources>`, enables inlining from the set of source files being compiled in the current compiler invocation. This option can also be used for compiling libraries. If the source files of a library are split up across multiple sbt projects, inlining is only done within each project. Note that in an incremental compilation, inlining would only happen within the sources being re-compiled – but in any case, it is recommended to only enable the optimizer in CI and release builds (and to run `clean` before building).
   
   While ordinarily this is exactly what you want even if you have a multi module sbt build, the reason I opted for `org.apache.pekko.**` instead is that we can abuse the fact that within context of akka/pekko core module you cannot mix different versions of different artifacts, even patch versions (i.e. you can't mix `pekko-actor:1.0.0` with `pekko-streams:1.0.1` and pekko contains a run time class path check to ensure this doesn't happen.
   
   So in summary, since we are mandating that every artifact within the pekko core project has to have the **SAME** version, it is safe to inline as long as we stick within the `org.apache.pekko` package. One thing that does need to be confirmed is if **every** artifact that this sbt build provides follow these rules or if its only some of them (i.e. pekko-actor/pekko-streams etc etc).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org