Skip to content

Commit afbe02d

Browse files
committed
Peformance test for WIP
Use these changes to compile the stdlib. You need to comment out AnyVal.scala and then use the following command on community-projects/stdLib213: sc -Ydetailed-stats *.scala */*.scala */*/*.scala */*/*/*.scala What I see is: Calls to `translucentSuperType` 53152: try norm KO -> 53086 try norm OK -> 66 The only computationally relevant part of this are calls to tryMatchAlias try match alias -> 528 Those calls suceed in 66 cases try norm OK -> 66 The successful normalizations all return types like this: try norm OK F[T1] *: scala.Tuple.Map[(T2, T3, T4, T5, T6, T7, T8), F] -> 3 Now it could be that trying the normalizations is costly, or that the normalized types cause exhaustivity checking to explode. Tht remains to be found out.
1 parent aadc10f commit afbe02d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4019,7 +4019,14 @@ object Types {
40194019
case tycon: TypeRef if tycon.symbol.isOpaqueAlias =>
40204020
tycon.translucentSuperType.applyIfParameterized(args)
40214021
case _ =>
4022-
tryNormalize.orElse(superType)
4022+
val x = tryNormalize
4023+
if x.exists then
4024+
record("try norm OK")
4025+
record(i"try norm OK $x")
4026+
x
4027+
else
4028+
record("try norm KO")
4029+
superType
40234030
}
40244031

40254032
inline def map(inline op: Type => Type)(using Context) =
@@ -4038,6 +4045,9 @@ object Types {
40384045
case tycon: TypeRef =>
40394046
def tryMatchAlias = tycon.info match {
40404047
case MatchAlias(alias) =>
4048+
record(i"try match alias")
4049+
record(i"try match alias $this in ${ctx.owner.ownersIterator.toList}%, %")
4050+
//new Error().printStackTrace()
40414051
trace(i"normalize $this", typr, show = true) {
40424052
MatchTypeTrace.recurseWith(this) {
40434053
alias.applyIfParameterized(args).tryNormalize

compiler/src/dotty/tools/dotc/util/Stats.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import collection.mutable
99

1010
@sharable object Stats {
1111

12-
final val enabled = false
12+
final val enabled = true
1313

1414
var monitored: Boolean = false
1515

0 commit comments

Comments
 (0)