Skip to content

Instantly share code, notes, and snippets.

View lrytz's full-sized avatar
🦉

Lukas Rytz lrytz

🦉
View GitHub Profile
@lrytz
lrytz / optimizer.md
Last active January 21, 2024 18:19

The Scala 2.12/2.13 Inliner and Optimizer

tl;dr.

  • Don't inline from your dependencies when publishing a library, it breaks binary compatibility. Use -opt-inline-from:my.package.** to only inline from packages within your library.
  • When compiling with the inliner enabled, ensure that the run-time classpath is exactly the same as the compile-time classpath.
  • Don't enable the optimizer for development: it breaks sbt's incremental compilation, and it makes the compiler slower. Only enable it for testing, on CI and to build releases.
  • The @inline annotation only has an effect if the inliner is enabled. It tells the inliner to always try to inline the annotated method or callsite.
  • Without the @inline annotation, the inliner generally inlines higher-order methods and forwarder methods. The main goal is to eliminate megamorphic callsites due to functions passed as argument, and to eliminate value boxing. Other optimizations are delegated to the JVM.
@lrytz
lrytz / z-automator.png
Last active February 4, 2023 21:20
Shortcut for Syntax Highlighting in Keynote
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases
#Warn ; Enable warnings to assist with detecting common errors
#UseHook ; Maybe more efficient? Prevents hotkey X to fire on Send {X}
SendMode Input ; Recommended for new scripts due to its superior speed and reliability
; Notes
; X::Y forwards modifiers, X::Send {Y} doesn't
; todo: alt emacs
diff --git a/ModuleSerializationProxy.class.asm b/ModuleSerializationProxy.class.asm
index ded4eb8..abdbadf 100644
--- a/ModuleSerializationProxy.class.asm
+++ b/ModuleSerializationProxy.class.asm
@@ -2,13 +2,6 @@
// access flags 0x31
public final class scala/runtime/ModuleSerializationProxy implements java/io/Serializable {
- // access flags 0x8
- static INNERCLASS scala/runtime/ModuleSerializationProxy$1 null null
--- unchecked-base.txt 2021-07-12 10:34:54.000000000 +0200
+++ unchecked-pr.txt 2021-07-12 10:34:26.000000000 +0200
@@ -1,9 +1,267 @@
+[akka-http] [warn] /akka-http-core/src/main/scala/akka/http/impl/engine/parsing/HttpMessageParser.scala:269:18: abstract type Output in type pattern scala.collection.mutable.ListBuffer[Output] is unchecked since it is eliminated by erasure
+[akka-http] [warn] /akka-http-core/src/main/scala/akka/http/impl/engine/parsing/HttpMessageParser.scala:269:18: abstract type Output in type pattern scala.collection.mutable.ListBuffer[Output] is unchecked since it is eliminated by erasure
+[akka-http] [warn] /akka-http-core/src/main/scala/akka/http/impl/engine/parsing/HttpMessageParser.scala:269:18: abstract type Output in type pattern scala.collection.mutable.ListBuffer[Output] is unchecked since it is eliminated by erasure
+[akka-http] [warn] /akka-http-core/src/main/scala/akka/http/impl/engine/parsing/HttpMessageParser.scala:89:20: abstract type Output in type pattern scala.collection.m
object Scala2 {
type Service[K <: Common.AbstractServiceKey[_]] = K#Protocol // error in 3: "K is not a legal path since it is not a concrete type"
}
// object Scala3 {
// type Service[K <: Common.AbstractServiceKey[_]] = K match {
// case Common.AbstractServiceKey[t] => t
// }
// }
trait ActorRef[-T] {
  def !(msg: T): Unit = ()
}

class Behavior[T]

object Behaviors {
  def receive[T](onMessage: T => Behavior[T]): Behavior[T] = ???
 def same[T]: Behavior[T] = ???
@lrytz
lrytz / fetchpr
Created March 11, 2021 08:22
fetchpr
#!/bin/bash
set -e
[[ $# == 1 ]] || {
echo "usage: $0 <pr-number>"
exit 1
}
pr=$1
object T {
import scala.util.matching._
object sessionNames {
// All values are configurable by passing e.g. -Dscala.repl.name.read=XXX
final def propOr(name: String): String = propOr(name, "$" + name)
final def propOr(name: String, default: String): String =
sys.props.getOrElse("scala.repl.name." + name, default)
// Prefixes used in repl machinery. Default to $line, $read, etc.
def line = propOr("line")
s12 -Ccom.google.guava:guava:30.1-jre
val ps = Set("scala.collection", "scala.collection.convert", "scala.collection.immutable", "scala.collection.mutable")
val cp = com.google.common.reflect.ClassPath.from(classOf[List[_]].getClassLoader)
import scala.collection.JavaConverters._
val topLevel = ps.flatMap(p => cp.getTopLevelClasses(p).asScala)
val all = topLevel.flatMap(c => {