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
Computing lub in WrappedArray.make takes 0.25s #6979
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6979?orig=1 |
@retronym said: (0) = {scala.reflect.internal.Types$TypeRef$$anon$6@4974}"Null"
(1) = {scala.reflect.internal.Types$TypeRef$$anon$5@4976}"scala.collection.mutable.WrappedArray.ofRef[AnyRef]"
(2) = {scala.reflect.internal.Types$TypeRef$$anon$6@4978}"scala.collection.mutable.WrappedArray.ofInt"
(3) = {scala.reflect.internal.Types$TypeRef$$anon$6@4980}"scala.collection.mutable.WrappedArray.ofDouble"
(4) = {scala.reflect.internal.Types$TypeRef$$anon$6@4982}"scala.collection.mutable.WrappedArray.ofLong"
(5) = {scala.reflect.internal.Types$TypeRef$$anon$6@4984}"scala.collection.mutable.WrappedArray.ofFloat"
(6) = {scala.reflect.internal.Types$TypeRef$$anon$6@4986}"scala.collection.mutable.WrappedArray.ofChar"
(7) = {scala.reflect.internal.Types$TypeRef$$anon$6@4988}"scala.collection.mutable.WrappedArray.ofByte"
(8) = {scala.reflect.internal.Types$TypeRef$$anon$6@4990}"scala.collection.mutable.WrappedArray.ofShort"
(9) = {scala.reflect.internal.Types$TypeRef$$anon$6@4992}"scala.collection.mutable.WrappedArray.ofBoolean"
(10) = {scala.reflect.internal.Types$TypeRef$$anon$6@4994}"scala.collection.mutable.WrappedArray.ofUnit" It them throws the LUB away to call import reflect.runtime.universe._, collection.mutable._, WrappedArray._
scala> val ts = List(typeOf[ofInt], typeOf[ofLong], typeOf[ofShort], typeOf[WrappedArray[AnyRef]], typeOf[ofUnit], typeOf[ofDouble], typeOf[ofFloat], typeOf[ofBoolean], typeOf[Null])
ts: List[reflect.runtime.universe.Type] = List(scala.collection.mutable.WrappedArray.ofInt, scala.collection.mutable.WrappedArray.ofLong, scala.collection.mutable.WrappedArray.ofShort, scala.collection.mutable.WrappedArray[scala.AnyRef], scala.collection.mutable.WrappedArray.ofUnit, scala.collection.mutable.WrappedArray.ofDouble, scala.collection.mutable.WrappedArray.ofFloat, scala.collection.mutable.WrappedArray.ofBoolean, Null)
scala> lub(ts)
res11: reflect.runtime.universe.Type = scala.collection.mutable.WrappedArray[_ >: Int with Long with Short with Unit with Double with Float with Boolean] For that particular method we can of course avoid the lub altogether by annotating the type of the match as I believe that this optimization is safe: scala/scala#1908, but it is only a slight improvement. |
@adriaanm said (edited on Jan 23, 2013 12:02:31 AM UTC): |
@gkossakowski said: Do you mean we can annotate the return type of the match? And yes, I meant investigating if there's a bug in lub computation somewhere which makes it explore more of a search space than it's needed. My main point here is that the code looks totally unreasonable to any Scala user and it triggers really bad behavior in type checker. The ticket is meant to investigate if we can do something about it. Probably the first step would be to create tool that allows detecting those problems, especially in IDE. Iulian said he would like to look into integrating my experiments with AspectJ-based profiling into Eclipse. I added him to watching list of this issue. |
@adriaanm said: |
@adriaanm said: |
@dragos said: |
@retronym said (edited on Apr 29, 2013 3:50:04 PM UTC): |
@JamesIry said: |
@retronym said: |
I found out that type-checking WrappedArray.make method (https://github.com/scala/scala/blob/master/src/library/scala/collection/mutable/WrappedArray.scala#L99) takes 0.25s and all that time is spent in calculating a single lub (probably coming from pattern match).
I'm creating this ticket in case somebody wanted to have a closer look into that.
The text was updated successfully, but these errors were encountered: