Skip to content
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

scala-reflect initialization takes too long #9783

Open
scabug opened this issue May 18, 2016 · 2 comments
Open

scala-reflect initialization takes too long #9783

scabug opened this issue May 18, 2016 · 2 comments

Comments

@scabug
Copy link

scabug commented May 18, 2016

scala-reflect library initialization takes over 600 milliseconds on my machine. When using sbt-revolver plugin for faster dev turnaround, it is a lot.

See attached test.

sergey@sergey:/tmp/1$ sbt run
[info] Loading global plugins from /home/sergey/.sbt/0.13/plugins
[info] Set current project to root-1 (in build file:/tmp/1/)
[info] Running Test 
time: 704ms
@scabug
Copy link
Author

scabug commented May 18, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9783?orig=1
Reporter: Sergey Alaev (salaev)
Affected Versions: 2.11.8
Attachments:

  • 1.tar.gz (created on May 18, 2016 5:34:37 PM UTC, 515 bytes)

@scabug
Copy link
Author

scabug commented Jun 7, 2016

@retronym said:
I have dug into this before and found the problem was that reflection ends up eagerly loading java.lang.Class far more eagerly than the regular compiler does the analagous operation, parsing a .class file into a Symbol.

These calls are made in PackageScope#lookupEntry:

https://github.com/scala/scala/blob/c8e6050c3c190dd064642b6b77fc179f27b0495d/src/reflect/scala/reflect/runtime/SymbolLoaders.scala#L134

I wasn't able to introduce laziness in the right places to fix this. The difficulty stems from the fact that runtime reflection can't enumerate the classpath, see the comments just above that link for some elaboration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants