Commit Graph

56 Commits

Author SHA1 Message Date
Jason Zaugg 5005abfef2 SD-232 Recycle classloaders to be anti-hostile to JIT.
The compiler interface subclasses `scala.tools.nsc.Global`,
and loading this new subclass before each `compile` task forces
HotSpot JIT to deoptimize larges swathes of compiled code. It's
a bit like SBT has rigged the dice to always descend the longest
ladder in a game of Snakes and Ladders.

The slowdown seems to be larger with Scala 2.12. There are a number
of variables at play, but I think the main factor here is that
we now rely on JIT to devirtualize calls to final methods in traits
whereas we used to emit static calls. JIT does a good job at this,
so long as classloading doesn't undo that good work.

This commit extends the existing `ClassLoaderCache` to encompass
the classloader that includes the compiler interface JAR. I've
resorted to adding a var to `AnalyzingCompiler` to inject the
dependency to get the cache to the spot I need it without binary
incompatible changes to the intervening method signatures.
2016-09-26 14:49:47 +10:00
Guillaume Martres 10265efd9c Make sbt aware of Dotty
This small set of changes, together with the compiler-bridge I wrote
(https://github.com/smarter/dotty-bridge) enables us to compile code
using Dotty in sbt, see https://github.com/smarter/dotty-example-project
for an example.
2016-01-03 20:35:29 +01:00
Pierre DAL-PRA 54d54b9f4f Replace procedure syntax by explicit Unit annotation 2015-08-04 10:07:38 +02:00
Pierre DAL-PRA b9171e59ad Simplify operations on collections 2015-08-01 02:25:17 +02:00
Pierre DAL-PRA 13b37cc987 Fix several warnings 2015-07-17 09:17:42 +02:00
henry 6545deacc8 Fix #1368 - getResources should never return null 2015-02-11 13:33:40 +00:00
Josh Suereth da1fc33b52 Removing printlns and adding the test, DOH. 2014-09-09 09:16:10 -04:00
Josh Suereth d2950da9dd Fix issue where ScalaInstance broke the thread-context-classloader for all scala classes.
The issue is that when you manually set a ScalaInstance, i.e. not one from Ivy, the
classpath which is returned for any given configuration ONLY uses Ivy.   This means that
the legitimate Scala JAR files that need to be on the classpath are missing from the list.
For some reason, the way we instantiate tests uses an unfiltered classloader against the
ScalaInstance, *BUT* the thread-context-classloader DOES use a filtered instance by
classpath.   This add the hook into the TestFramework runner creation so that
the classpath accurately reflects the jars needed.

cc @rkuhn
2014-09-09 08:56:51 -04:00
Josh Suereth 50460fad28 Add toString methods to classloaders, for debugging.
* Add toString methods to all classloader classes.
2014-09-09 08:56:20 -04:00
Josh Suereth 4311f87d64 Remove flaky test.
Fixes #1390
2014-06-05 12:39:44 -04:00
Josh Suereth 273024a238 Add special hook to diagnose travis failing test. 2014-06-04 11:33:02 -04:00
Josh Suereth 87306524a8 Improve error message further. 2014-06-03 13:57:27 -04:00
Josh Suereth 2c3f40eb02 Improve test failure message for #1390. 2014-06-02 15:10:17 -04:00
Josh Suereth 244abd3b6f Scalariforming test code 2014-05-07 11:52:23 -04:00
Eugene Yokota adb41611cf added scalariform 2014-05-01 12:50:07 -04:00
Mark Harrah b8619f4aae Main part of integrating natures into project loading. 2014-01-24 14:34:15 -05:00
Mark Harrah 78178f8716 More API docs for the classpath module 2013-08-16 14:22:14 -04:00
Mark Harrah 39f6456a81 source compatibility of ClasspathUtilities.isArchive for sbt-assembly
default parameters and eta-expansion don't interact well
2013-06-20 16:37:14 -04:00
Mark Harrah 5dc671c7f8 Synchronize ClassLoaderCache and the Scala provider cache.
Construction of Scala providers was already properly synchronized jvm and machine-wide.
The cache on top of construction was not and neither was the newer ClassLoaderCache.
This could cause the same Scala version to be loaded in multiple class loaders, taking
up more permgen space and possibly decreasing performance due to less effective jit.

The issue is very rare in practice for 0.13 because of the low probability of contention
on ClassLoaderCache.  This is because the work for a cache miss is mainly the construction
of a URLClassLoader.  In 0.12, however, the work potentially involved network access and
class loading (not just class loader construction), thus greatly increasing the probability
of contention and thus duplicate work (i.e. class loader construction).

When there is contention, multiple class loaders are constructed and then preserved by the
scalaInstance task in each project throughout the first task execution.  Only when multiple
scalaInstance tasks execute simultaneously and only during the first execution does this occur.
(Technically, it could still happen later, but it doesn't in practice.)

This means that the number of duplicate class loaders should quickly saturate instead of growing
linearly with the number of projects.  It also means that the impact depends on the exact
tree structure of projects.  A linear chain of dependencies will be unaffected, but a build with
independent leaves may be limited by the number of cores.  The number of cores affects
the number of threads typically used by the task engine, which limits the number of concurrently
executing scalaInstance tasks.

In summary, this might affect the first, cold compilation of a multi-module project with
independent leaves on a multi-core machine with Scala version different from the version used
for sbt.  It might increase the maximum permgen requirements as well as slow the jit compilation
by up to one task execution.  Subsequent compilations should be unaffected and the permgen
utilization return to be as expected.
2013-06-19 21:38:06 -04:00
Mark Harrah 8372d0a751 handle directory classpath entries in ClasspathFilter. Fixes #783. 2013-06-15 23:55:05 -04:00
Mark Harrah 77001a4259 drop canonicalization of files on classpath and other cleanup. Fixes #723. 2013-04-09 20:13:06 -04:00
Mark Harrah b990a29c09 Undeprecate ScalaInstance.libraryJar, which will be reliable for modularized Scala. 2013-04-08 09:21:59 -04:00
Mark Harrah f6d73128fc deprecations 2013-02-25 09:24:04 -05:00
Mark Harrah 5b5577a187 Replace Scala jars in UpdateReport with ScalaProvider jars in more situations. Fixes #661.
Specifically, when the Scala version for sbt is the same as that for the project being built,
the jars in UpdateReport should be the same as those in ScalaProvider.  This is because the
loader will come from the ScalaProvider, which uses jars in the boot directory instead of the
cache.  The first part of the fix for #661 checks that loaded classes come from the classpath
and so they need to line up.
2013-02-21 20:44:26 -05:00
Mark Harrah bd0f208302 Class loader that restricts loading to a classpath. Ref #661.
It is now used for consoleProject, run, and test.  This loader verifies
that all classes loaded through it came from a particular classpath or
from the "root" loader.  Root loader here is the launcher loader so that
those classes with native bindings come from that shared loader.
2013-02-21 20:44:26 -05:00
Mark Harrah cdf61683df Remove unused class loader implementations 2013-02-21 20:44:26 -05:00
Grzegorz Kossakowski ef39aeb9c1 Follow source layout convention supported by Eclipse.
Moved source files so directory structure follow package
structure. That makes it possible to use Scala Eclipse plugin
with sbt's source code.
2012-12-07 10:27:08 -08:00
Mark Harrah e47a357ab7 Resolve Scala version for projects in the normal `update` task.
1. Scala jars won't be copied to the boot directory, except for those needed to run sbt.
2. Scala SNAPSHOTs behave like normal SNAPSHOTs.  In particular, running `update` will properly re-resolve the dynamic revision.
3. Scala jars are resolved using the same repositories and configuration as other dependencies.
4. Classloaders (currently, Scala classloaders) are cached by the timestamps of entries instead of Scala class loaders being cached by version.

TODO: Support external dependency configuration
2012-11-17 20:23:06 -05:00
Mark Harrah ba8aa932fb scala-reflect.jar for the ScalaInstance derived from scalaHome 2012-06-16 23:40:52 -04:00
Mark Harrah d837f869bd using some of the embedding interfaces 2012-04-18 11:02:52 -04:00
Mark Harrah a36212886d Merge pull request #427 from pvlugter/root-loader
Use system classloader when finding root classloader
2012-04-13 02:59:48 -07:00
Peter Vlugter 7b7716953f Use system classloader when finding root classloader 2012-04-13 11:51:15 +12:00
Mark Harrah 2a84a80d5b clean up scalaOrg changes 2012-04-12 17:31:28 -04:00
Vojin Jovanovic 079a2c1bda Minimizing effects of scalaOrganization key addition. 2012-04-11 12:55:01 +02:00
Vojin Jovanovic cbb8caef0c Backwards compatibility check for getScala method.
Added groupId dependant baseDirectoryName.
General code cleanup.
2012-04-11 04:04:21 +02:00
Vojin Jovanovic 0f6a50daee Addressing https://github.com/harrah/xsbt/pull/418
Changed the order of parameters in getScala method.
Changed the key name to scalaOrganization (scala-organization).
Augmented description of the key.
Minor fixes.
2012-04-05 12:19:49 +02:00
Vojin Jovanovic 182b7c655f Adding `scalaOrg` setting key for scala clones.
Adding scalaOrg key that specifies organization (artifactId) of scala used in the project. The change does not affect version checks for dependecies and LauncherConfiguration.

Modified scalaProvider cache in Launcher to use (scalaOrg, version) as a key.

Downloaded jars are stored in the folder scala-.../lig-<scalaOrg> if scalaOrg is not default.

scala-org is an advanced setting so it can not be used in build.sbt.
2012-04-04 19:06:55 +02:00
Mark Harrah 0f447c201e directly read compiler.properties so that Scala classes don't need to be loaded when no work needs to be done. 2011-10-05 18:09:27 -04:00
Mark Harrah 3ce7c0411d search java.library.path for default run/test loader 2011-08-05 21:56:32 -04:00
Mark Harrah 7ea35daec2 class loader extension to handle native libraries loaded in multiple class loaders 2011-08-05 21:56:32 -04:00
Mark Harrah f52726c221 add ability to specify actual version for ScalaInstance. ref #127. 2011-07-26 13:34:02 -04:00
Mark Harrah b8bf259500 support starr as a scala home 2011-07-16 12:31:15 -04:00
Mark Harrah 2343a55bb9 replace Path with RichFile 2011-05-14 18:21:41 -04:00
Mark Harrah d09aab03be better location for class loaders (ClassLoaders.scala) 2011-04-15 18:22:57 -04:00
Mark Harrah c505b01ba6 fix - error 2011-03-05 07:37:03 -05:00
Mark Harrah ec8c5434af jline support for 2.9 2011-03-05 05:58:10 -05:00
Mark Harrah 72261548ef use java.util.Linked* instead of scala's 2011-01-22 16:21:22 -05:00
Mark Harrah de3ad8c860 eliminate temporary directory for injecting resources into a class loader 2010-11-13 20:16:44 -05:00
Mark Harrah 37904a1644 replace unordered collections in several locations with ordered ones 2010-10-26 18:09:33 -04:00
Mark Harrah d0fa1eb461 * move Environment classes to util/env module
* move TrapExit, SelectMainClass to run module
* rearrange some compilation-related code
* Jetty-related code moved to web module
2010-07-14 19:24:50 -04:00