Scala Programming Language
  1. Scala Programming Language
  2. SI-5862

very slow compilation due to humonguous LUB

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.0, Scala 2.10.0
    • Fix Version/s: Scala 2.10.0
    • Component/s: Type Checker
    • Labels:
      None

      Description

      Only typechecking takes 10 seconds. If I add the commented type ascription, it goes down to 700ms.

      It looks like the least-upper bound computation for the 'if' takes most of this time.

      (Maybe this can be minimized further)

      package test
      
      import java.io.DataOutput
      import java.io.DataInput
      
      /** Interface for writing outputs from a DoFn. */
      trait Emitter[A] {
        def emit(value: A): Unit
      }
      
      /** A wrapper for a 'map' function tagged for a specific output channel. */
      abstract class TaggedMapper[A, K, V]
          (val tags: Set[Int])
          (implicit val mA: Manifest[A], val wtA: WireFormat[A],
                    val mK: Manifest[K], val wtK: WireFormat[K], val ordK: Ordering[K],
                    val mV: Manifest[V], val wtV: WireFormat[V])
        extends Serializable {
      }
      
      /** Type-class for sending types across the Hadoop wire. */
      trait WireFormat[A]
      
      class MapReduceJob {
        trait DataSource
        
        import scala.collection.mutable.{ Set => MSet, Map => MMap }
        private val mappers: MMap[DataSource, MSet[TaggedMapper[_, _, _]]] = MMap.empty
        
        def addTaggedMapper[A, K, V](input: DataSource, m: TaggedMapper[A, K, V]): Unit = {
          if (!mappers.contains(input))    
            mappers += (input -> MSet(m))
          else  
            mappers(input) += m // : Unit
      
          m.tags.foreach { tag =>
          }
        }
      }
      

        Activity

        Hide
        Jason Zaugg added a comment -

        Improved a bit recently:

          ~/code/scala time scalac210 sandbox/t5862.scala
        
        real	0m15.253s
        user	0m32.602s
        sys	0m0.875s
          ~/code/scala time ./build/quick/bin/scalac sandbox/t5862.scala
        
        real	0m7.675s
        user	0m15.998s
        sys	0m0.793s
        

        Both take about 4.8s with the type ascription.

        Show
        Jason Zaugg added a comment - Improved a bit recently: ~/code/scala time scalac210 sandbox/t5862.scala real 0m15.253s user 0m32.602s sys 0m0.875s ~/code/scala time ./build/quick/bin/scalac sandbox/t5862.scala real 0m7.675s user 0m15.998s sys 0m0.793s Both take about 4.8s with the type ascription.
        Hide
        Iulian Dragos added a comment -

        Jason, thanks for the update!

        We could probably mark it as fixed, but ideally we'd know the commit. It should be backported to 2.9.x

        Show
        Iulian Dragos added a comment - Jason, thanks for the update! We could probably mark it as fixed, but ideally we'd know the commit. It should be backported to 2.9.x
        Hide
        Jason Zaugg added a comment -
        Show
        Jason Zaugg added a comment - I'd guess: https://github.com/scala/scala/commit/1dd02bdd72
        Hide
        Martin Odersky added a comment -
        Show
        Martin Odersky added a comment - Indeed the fixing commit is https://github.com/scala/scala/commit/1dd02bdd72 .

          People

          • Assignee:
            Martin Odersky
            Reporter:
            Iulian Dragos
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development