Aladdin - Scala Bugtracking
[#1019] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Martin Martin fixed 2007-03-24 17:52:29.0
subject possible inefficiency in typer
code
   [locker] java.lang.StackOverflowError
   [locker] 	at java.util.LinkedHashMap.get(LinkedHashMap.java:273)
   [locker] 	at java.io.ExpiringCache.entryFor(ExpiringCache.java:83)
   [locker] 	at java.io.ExpiringCache.get(ExpiringCache.java:58)
   [locker] 	at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:376)
   [locker] 	at java.io.File.getCanonicalPath(File.java:531)
   [locker] 	at scala.tools.nsc.io.PlainFile.hashCode(PlainFile.scala:47)
   [locker] 	at scala.collection.mutable.FlatHashTable$class.elemHashCode(FlatHashTable.scala:137)
   [locker] 	at scala.collection.mutable.HashSet.elemHashCode(HashSet.scala:31)
   [locker] 	at scala.collection.mutable.FlatHashTable$class.addEntry(FlatHashTable.scala:61)
   [locker] 	at scala.collection.mutable.HashSet.addEntry(HashSet.scala:31)
   [locker] 	at scala.collection.mutable.HashSet.$plus$eq(HashSet.scala:35)
   [locker] 	at scala.tools.nsc.typechecker.Infer$Inferencer.checkAccessible(Infer.scala:343)
what happened
When looking at the top of the stacktrace for the pattern matcher,
I saw the code given above. checkAccessible is a hotspot in the compiler; it is
run twice for every identifier use (once in typer another time in erasure).
Now, it seems that every such call constructs the canonical path of a sourcefile to compute a hashcode to check \
whether the source file is in the depends set.
Looks like a lot of work that's repeated all over again. I am not sure whether this is a performance bottleneck \
or not, but prudence dictates that we should optimize this! Probably a simple hash-consing for sourcefiles would\
 be enough.
what expected
[back to overview]
Changes of this bug report
Martin  edited on  2007-04-17 16:30:41.0