Commit 36088c3
committed
Sidestep Zinc and use the compiler interface directly
Basic benchmarking shows that we're incurring a ~49% overhead from using
Zinc instead of the Scala compiler directly. That is, we wrote a basic
worker that invokes the Scala 2 compiler programmatically via
`scala.tools.nsc.Main`, and found that it was ~49% faster
across-the-board.
This doesn't necessarily mean that we can speed up `ZincRunner` by 49%.
A lot of that time is spent in compilation phases
[added](https://github.com/scala/scala/blob/2.13.x/src/sbt-bridge/scala/tools/xsbt/CallbackGlobal.scala#L166)
by the compiler bridge (implementation of the compiler interface)
itself. There are three of these phases; they're responsible for:
1. Mapping generated `.class` files to sources
2. Analyzing depedendencies between code
3. Producing the analysis information outputted by Zinc
We rely on 2 and 3 for:
- Dependency checking
- Detecting main classes
- Test discovery
We only use 2 and 3, and although it's likely the phases could be
slimmed down to only extract the information we need, implementing them
ourselves would add a lot of complexity to `ZincRunner` and make it
less portable . There's also no guarantee
that we could do a better job.
What can be eliminated is all the overhead related to incremental
compilation. We haven't used incremental compilation for years and have
no intention of re-enabling it.
This commit isn't about ripping out Zinc entirely; we still use Zinc for
the following things:
- Classloading the compiler interface from the compiler classpath
- Implementations of various `xsbti.*` traits and interfaces1 parent 321e0a9 commit 36088c3
File tree
10 files changed
+361
-447
lines changed- src/main/scala
- higherkindness/rules_scala/workers/zinc/compile
- sbt/internal/inc/classfile
- tests/compile/log_level
10 files changed
+361
-447
lines changedLines changed: 92 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
Lines changed: 0 additions & 66 deletions
This file was deleted.
Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 0 additions & 41 deletions
This file was deleted.
0 commit comments