Commit Graph

80 Commits

Author SHA1 Message Date
Ethan Atkins 38d67cfdf0 Improve sbt build load time by 25%
The sbt project load made a number of relatively inefficient
transformations of scala collecitons. I went through and found the slow
parts during project loading and made my best attempt at fixing them.
The most significant changes I made were in places using IMap. An IMap
is more or less a wrapper around an immutable Map. It can be much faster
to construct an IMap by creating a java mutable hashmap, wrapping it a
scala Map that delegates to the underlying java hashmap (with a copy on
write if the map is modified) and constructing the IMap from the wrapped
map. It was also in many cases to parallelize some transformations
wherever the order didn't matter.

After applying all of these changes, I found that loading the sbt
project took generally between 8.5 and 9 seconds on my laptop. With
1.3.13, it hovered around 11.5 seconds. I saw a similar speedup in zinc.
The biggest specific improvement was that generating the compiled map
dropped from between 3.5-4 seconds to pretty consistently being around
1.5 seconds.
2020-07-26 19:52:26 -07:00
Ethan Atkins bc4fe0a31a Cross build collectionProj 2020-07-10 13:37:54 -07:00
Ethan Atkins 6565618a15 Cache compiled map during build load
The continuous command recompiles the setting graph into a CompiledMap
data structure so that it can determine which files it needs to
transitively monitor during watch. Generating the CompiledMap can be
very slow for large projects (5 seconds or so on my computer in the sbt
project) and this startup cost is paid every time the user enters a
watch with `~`. To avoid this, we can cache the compile map that is
generated during the initial settings evaluation.

The only real drawback I can see is that the compiled map is guaranteed
to remain in memory so long as the BuildStructure instance that holds it
is alive. Given the performance benefit, this seems like a worthwhile
tradeoff.
2020-07-03 14:08:26 -07:00
Ethan Atkins e53c8f6f01 Add Util.ignoreResult
This adds a convenience macro for appending `()` to an expression if it
is the last expression in a block that is supposed to return Unit.
2020-06-24 19:19:06 -07:00
Ethan Atkins 52d19d8f0c Refactor Signal for graalvm
The graalvm issues warnings about the objects defined in
Signal.register, so I made them top level private classes instead.
2020-06-24 19:19:06 -07:00
eugene yokota 2b557851ca
Merge pull request #5041 from jsoref/https
Https
2020-06-14 17:34:58 -04:00
Eugene Yokota 2feecf8a1f Selective functor
This implements Selective functor for `Either[A, B]` "task" (`Initialize[Task[Either[A, B]]]`).
The selective functor allows an encoding of if-expression:

```
  def ifS[A](
      x: Def.Initialize[Task[Boolean]]
  )(t: Def.Initialize[Task[A]])(e: Def.Initialize[Task[A]]): Def.Initialize[Task[A]]
```

The benefit of this approach is that task dependencies are still visible to inspect command.
2020-05-17 23:36:04 -04:00
nigredo-tori 11b7173ec7
Fix a message about an undefined setting
`defining` seems to be the setting or a task that references `referencedKey`, not the other way around.
2020-03-13 12:53:44 +07:00
Dale Wijnand 2608f8ade6 Document parts of AList & components of TupleSyntax
Also, extract the AList.SplitK type lambda helper for call-site reuse.
2020-02-17 07:15:37 +00:00
Eugene Yokota 54b3405f42 apply -Yno-lub
To demonstrate [-Yno-lub](http://eed3si9n.com/stricter-scala-with-ynolub), this shows the code changes that removes lubing (Not all subprojects are done).

After I made the changes, I switched the Scala back to normal 2.12.10.
2019-10-13 23:46:23 -04:00
Eugene Yokota 5d0793fece Scala 2.12.10 2019-09-11 23:02:50 -04:00
Josh Soref 747416173a https://apocalisp.wordpress.com 2019-09-05 14:10:59 -04:00
xuwei-k dfe789d7c6 avoid deprecated /: and :\
use foldLeft and foldRight

https://github.com/scala/scala/blob/v2.13.0/src/library/scala/collection/IterableOnce.scala#L682-L686
2019-08-30 11:20:53 +09:00
xuwei-k 1f3ce5f9ee use Vector instead of List. avoid O(n) append 2019-08-29 21:44:31 +09:00
Ethan Atkins 4bb2f4e968 Used Seq instead of Stream
Streams generically perform poorly and weren't needed here.
2019-08-22 20:35:12 -07:00
Ethan Atkins 1700b89ea4 Parallelize Init.addLocal
During akka startup, addLocal was caused twice and prior to this change,
it took roughly 200ms per call on my computer. After this change, it
took about 100ms.
2019-08-22 20:35:11 -07:00
Ethan Atkins a3ac4c76a6 Bump scalafmt
Intellij had issues resolving 2.0.0-RCX so it will be nice to be using
the latest.
2019-07-18 12:40:21 -07:00
Dale Wijnand 4e89e8ace5
Document helper functions in BuildStructure
Also define LoadedBuildUnit#projects & BuildUnit#thisRootProject, &
cleanup AttributeKey & BasicAttributeMap
2019-06-02 23:28:53 +01:00
Eugene Yokota 1e157b991a apply formatting 2019-04-20 03:23:54 -04:00
Ethan Atkins d178f13fc0 Rename generic parameter
I was seeing a number of compiler warnings about the type parameter
Scope:
    Settings.scala:55:12: type parameter Scope defined in trait Init shadows class Scope defined in package util. You may want to rename your type parameter, or possibly remove it.

I'm not sure why I wasn't seeing these before, but the fix is simple.
2019-03-28 08:31:10 -07:00
Ethan Atkins efa52143d0 Make types private
While the AnyLeft and AnyRight types are necessary to make the extension
class work, I don't want to leak the AnyLeft or AnyRight traits into the
public api. It wasn't neceessary to annotate `some`, but it's good
practice to annotate anything public anyway.
2019-01-31 21:47:33 -08:00
Ethan Atkins 9b40a0e585 Add meaningful toString to TypeFunctions
It can be hard to debug these because the toString output for a kind
projector plugin provided lambda is inscrutable.
2019-01-31 21:47:33 -08:00
Ethan Atkins 16e7c70035 Lint TypeFunctions.scala 2019-01-31 21:47:33 -08:00
Eugene Yokota 4ff4f6e45e Update header 2018-09-14 04:53:36 -04:00
xuwei-k ae1fdff968 use SAM type 2018-07-09 13:06:34 +09:00
xuwei-k 98eca81b17 use val instead of var 2018-07-08 22:35:31 +09:00
eugene yokota eb942f8e5f
Merge pull request #4003 from eed3si9n/wip/opt-delegation3
optimize scope delegation
2018-06-27 15:31:21 -04:00
Dale Wijnand 8f4b8abb7b
Run scalafmt & test:scalafmt 2018-04-24 16:12:10 +01:00
Eugene Yokota 07e26a1dcf don't use toStream
Ref #3979
toStream doesn't help performance.
2018-03-10 18:43:43 -05:00
Dale Wijnand 21eb1f0f12
Cleanup Attributes 2018-03-06 11:54:12 +00:00
Dale Wijnand 5daf10d6c7
Tweak the description of KList 2018-01-23 17:14:27 +00:00
Dale Wijnand b80a6b217b
Remove all warnings from collectionProj 2017-12-12 13:02:18 +00:00
Dale Wijnand 9f1d60be60
Rewrite to polymorphic function syntax 2017-10-25 10:23:46 +01:00
Dale Wijnand f662fdda8e
Rewrite to function syntax 2017-10-25 10:22:48 +01:00
Dale Wijnand fb17cc393f
Rewrite to inline syntax 2017-10-25 10:22:48 +01:00
Dale Wijnand 35c3542492
Get rid of Fn1 2017-10-25 10:21:00 +01:00
Dale Wijnand 34f9e56311
Introduce and use KList.Aux 2017-10-25 10:15:29 +01:00
Dale Wijnand 3cd8f4dadf
Simplify Initialize.joinAny 2017-10-25 10:15:29 +01:00
Dale Wijnand 81c5eaec33 Merge pull request #3633 from dwijnand/misc-2017-10-12
Misc 2017-10-12
2017-10-24 20:37:20 +01:00
Simon Schäfer 38f550deef Fix warnings in util-collection project
There were warnings because of
- unused pattern match values
- deprecations
- a Xlint bug in scalac
2017-10-19 13:07:24 +02:00
Dale Wijnand 86be5359e7
Initial scaladoc Initialize/Keyed/KeyedInitialize 2017-10-12 20:31:25 +01:00
Dale Wijnand a41727fb17
Add, configure & enforce file headers 2017-10-05 09:03:40 +01:00
Eugene Yokota 33a01f3ceb Unified slash syntax
Fixes sbt/sbt#1812

This adds unified slash syntax for both sbt shell and the build.sbt DSL.
Instead of the current `<project-id>/config:intask::key`,
this adds `<project-id>/<config-ident>/intask/key` where <config-ident> is the Scala identifier notation for the configurations like `Compile` and `Test`.

This also adds a series of implicits called `SlashSyntax` that adds `/` operators to project refererences, configuration, and keys such that the same syntax works in build.sbt.

These examples work for both from the shell and in build.sbt.

    Global / cancelable
    ThisBuild / scalaVersion
    Test / test
    root / Compile / compile / scalacOptions
    ProjectRef(uri("file:/xxx/helloworld/"),"root")/Compile/scalacOptions
    Zero / Zero / name

The inspect command now outputs something that can be copy-pasted:

    > inspect compile
    [info] Task: sbt.inc.Analysis
    [info] Description:
    [info] 	Compiles sources.
    [info] Provided by:
    [info] 	ProjectRef(uri("file:/xxx/helloworld/"),"root")/Compile/compile
    [info] Defined at:
    [info] 	(sbt.Defaults) Defaults.scala:326
    [info] Dependencies:
    [info] 	Compile/manipulateBytecode
    [info] 	Compile/incCompileSetup
    [info] Reverse dependencies:
    [info] 	Compile/printWarnings
    [info] 	Compile/products
    [info] 	Compile/discoveredSbtPlugins
    [info] 	Compile/discoveredMainClasses
    [info] Delegates:
    [info] 	Compile/compile
    [info] 	compile
    [info] 	ThisBuild/Compile/compile
    [info] 	ThisBuild/compile
    [info] 	Zero/Compile/compile
    [info] 	Global/compile
    [info] Related:
    [info] 	Test/compile
2017-09-28 01:01:43 -04:00
Eugene Yokota 348a077797 implement tokenfile authentication 2017-09-21 23:05:48 -04:00
Dale Wijnand 805b76f3d4
Add back, re-configure & re-enable Scalafmt 2017-08-10 16:35:23 +01:00
Eugene Yokota 467617a4b9 Implement withRank 2017-07-25 01:50:53 -04:00
Eugene Yokota 7b2b7d696b Don't wrap InputStream for Windows
Ref #3282

We used to wrap InputStream so it will inject Thread.sleep, which then allows the thread to be cancelled, emulating a non-blocking readLine. This trick doesn't seem to work for Windows.
For non-Cygwin, actually just removing the wrapping does the job, but I couldn't get it to work for Cygwin.

To test, run some command via network, and then type `show name` into the terminal. On Cygwin, it will not respond.
2017-07-22 03:34:10 -04:00
Eugene Yokota 8d159b87a2 Fix test 2017-07-17 02:14:17 -04:00
Dale Wijnand dc2d4d613f
Format in-sourced util modules 2017-07-07 12:12:59 +01:00
Dale Wijnand 9494967e05
Upgrade util/lm/zinc & config build for util modules
Welcome back home!
2017-07-07 12:11:59 +01:00