Skip to content

Commit

Permalink
Merge branch 'master' into add-return-type
Browse files Browse the repository at this point in the history
  • Loading branch information
guizmaii authored Oct 19, 2023
2 parents 99e3a4c + 4033d56 commit 0545e0f
Show file tree
Hide file tree
Showing 97 changed files with 120 additions and 4,817 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
fail-fast: false
matrix:
scala: [2.12.x, 2.13.x, 3.3.x]
module: [base, db, async, codegen, bigdata]
module: [base, db, codegen, bigdata]
include:
- scala: 2.12.x
scala_short: 212
Expand All @@ -42,8 +42,6 @@ jobs:
# For now, only do the `base` build for Scala 3
- scala: 3.3.x
module: db
- scala: 3.3.x
module: async
- scala: 3.3.x
module: codegen
- scala: 3.3.x
Expand Down
92 changes: 8 additions & 84 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ lazy val dbModules = Seq[sbt.ClasspathDep[sbt.ProjectReference]](
`quill-jdbc-zio`
)

lazy val jasyncModules = Seq[sbt.ClasspathDep[sbt.ProjectReference]](
`quill-jasync`,
`quill-jasync-postgres`,
`quill-jasync-mysql`,
`quill-jasync-zio`,
`quill-jasync-zio-postgres`
)

lazy val codegenModules = Seq[sbt.ClasspathDep[sbt.ProjectReference]](
`quill-codegen`,
`quill-codegen-jdbc`,
Expand All @@ -70,10 +62,10 @@ lazy val bigdataModules = Seq[sbt.ClasspathDep[sbt.ProjectReference]](
)

lazy val allModules =
baseModules ++ dbModules ++ jasyncModules ++ codegenModules ++ bigdataModules ++ docsModules
baseModules ++ dbModules ++ codegenModules ++ bigdataModules ++ docsModules

lazy val scala213Modules =
baseModules ++ dbModules ++ jasyncModules ++ codegenModules ++ bigdataModules
baseModules ++ dbModules ++ codegenModules ++ bigdataModules

lazy val scala3Modules = Seq[sbt.ClasspathDep[sbt.ProjectReference]](`quill-engine`, `quill-util`)

Expand Down Expand Up @@ -112,15 +104,12 @@ lazy val filteredModules = {
case "db" =>
println("SBT =:> Compiling Database Modules")
dbModules
case "async" =>
println("SBT =:> Compiling Async Database Modules")
jasyncModules
case "codegen" =>
println("SBT =:> Compiling Code Generator Modules")
codegenModules
case "nocodegen" =>
println("Compiling Not-Code Generator Modules")
baseModules ++ dbModules ++ jasyncModules ++ bigdataModules
baseModules ++ dbModules ++ bigdataModules
case "bigdata" =>
println("SBT =:> Compiling Big Data Modules")
bigdataModules
Expand Down Expand Up @@ -206,7 +195,7 @@ lazy val `quill-engine` =
.settings(commonSettings: _*)
.settings(
libraryDependencies ++= Seq(
"com.typesafe" % "config" % "1.4.2",
"com.typesafe" % "config" % "1.4.3",
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5",
("com.github.takayahilton" %% "sql-formatter" % "1.2.1").cross(CrossVersion.for3Use2_13),
"io.suzaku" %% "boopickle" % "1.4.0",
Expand All @@ -222,7 +211,7 @@ lazy val `quill-core` =
.settings(commonSettings: _*)
.settings(
libraryDependencies ++= Seq(
"com.typesafe" % "config" % "1.4.2",
"com.typesafe" % "config" % "1.4.3",
"dev.zio" %% "zio-logging" % "2.1.14",
"dev.zio" %% "zio" % Version.zio,
"dev.zio" %% "zio-streams" % Version.zio,
Expand Down Expand Up @@ -318,8 +307,8 @@ lazy val `quill-doobie` =
.settings(jdbcTestingSettings: _*)
.settings(
libraryDependencies ++= Seq(
"org.tpolecat" %% "doobie-core" % "1.0.0-RC2",
"org.tpolecat" %% "doobie-postgres" % "1.0.0-RC2" % Test
"org.tpolecat" %% "doobie-core" % "1.0.0-RC4",
"org.tpolecat" %% "doobie-postgres" % "1.0.0-RC4" % Test
)
)
.dependsOn(`quill-jdbc` % "compile->compile;test->test")
Expand Down Expand Up @@ -421,71 +410,6 @@ lazy val `quill-spark` =
.dependsOn(`quill-sql` % "compile->compile;test->test")
.enablePlugins(MimaPlugin)

lazy val `quill-jasync` =
(project in file("quill-jasync"))
.settings(commonSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
"com.github.jasync-sql" % "jasync-common" % "2.2.4",
"org.scala-lang.modules" %% "scala-java8-compat" % "0.9.1"
)
)
.dependsOn(`quill-sql` % "compile->compile;test->test")
.enablePlugins(MimaPlugin)

lazy val `quill-jasync-postgres` =
(project in file("quill-jasync-postgres"))
.settings(commonSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
"com.github.jasync-sql" % "jasync-postgresql" % "2.2.4"
)
)
.dependsOn(`quill-jasync` % "compile->compile;test->test")
.enablePlugins(MimaPlugin)

lazy val `quill-jasync-mysql` =
(project in file("quill-jasync-mysql"))
.settings(commonSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
"com.github.jasync-sql" % "jasync-mysql" % "2.2.4"
)
)
.dependsOn(`quill-jasync` % "compile->compile;test->test")
.enablePlugins(MimaPlugin)

lazy val `quill-jasync-zio` =
(project in file("quill-jasync-zio"))
.settings(commonSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
"com.github.jasync-sql" % "jasync-common" % "2.2.4",
"org.scala-lang.modules" %% "scala-java8-compat" % "0.9.1",
"dev.zio" %% "zio" % Version.zio,
"dev.zio" %% "zio-streams" % Version.zio
)
)
.dependsOn(`quill-zio` % "compile->compile;test->test")
.dependsOn(`quill-sql` % "compile->compile;test->test")
.enablePlugins(MimaPlugin)

lazy val `quill-jasync-zio-postgres` =
(project in file("quill-jasync-zio-postgres"))
.settings(commonSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
"com.github.jasync-sql" % "jasync-postgresql" % "2.2.4"
)
)
.dependsOn(`quill-jasync-zio` % "compile->compile;test->test")
.enablePlugins(MimaPlugin)

lazy val `quill-cassandra` =
(project in file("quill-cassandra"))
.settings(commonSettings: _*)
Expand All @@ -494,7 +418,7 @@ lazy val `quill-cassandra` =
libraryDependencies ++= Seq(
"com.datastax.oss" % "java-driver-core" % "4.17.0",
(CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) => "org.scala-lang.modules" %% "scala-java8-compat" % "0.8.0"
case Some((2, 12)) => "org.scala-lang.modules" %% "scala-java8-compat" % "0.9.1"
case _ => "org.scala-lang.modules" %% "scala-java8-compat" % "1.0.2"
})
)
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile-sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM hseeberger/scala-sbt:8u312_1.5.5_2.13.6
FROM sbtscala/scala-sbt:eclipse-temurin-focal-17.0.8.1_1_1.9.6_3.3.1
MAINTAINER mdedetrich@gmail.com

RUN apt-get update
Expand Down
10 changes: 0 additions & 10 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,6 @@ function db_build() {
./build/aware_run.sh "sbt -Dmodules=db $SBT_ARGS test"
}

function async_build() {
echo "build.sh =:> Async Build Specified"
wait_for_mysql_postgres
echo "build.sh =:> Starting Async Build Primary"
sbt -Dmodules=async $SBT_ARGS test
}

function codegen_build() {
echo "build.sh =:> Codegen Build Specified"
wait_for_databases
Expand Down Expand Up @@ -236,9 +229,6 @@ elif [[ $modules == "js" ]]; then
elif [[ $modules == "finagle" ]]; then
echo "build.sh =:> Build Script: Doing Finagle Database Build"
finagle_build
elif [[ $modules == "async" ]]; then
echo "build.sh =:> Build Script: Doing Async Database Build"
async_build
elif [[ $modules == "codegen" ]]; then
echo "build.sh =:> Build Script: Doing Code Generator Build"
codegen_build
Expand Down
2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ docker-compose run --rm sbt sbt "test-only io.getquill.context.sql.SqlQuerySpec"

Run all tests in specific sub-project:
```bash
docker-compose run --rm sbt sbt "project quill-async" test
docker-compose run --rm sbt sbt "project quill-jdbc-zio" test
```

Run specific test in specific sub-project:
Expand Down
52 changes: 52 additions & 0 deletions docs/compiler-performance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
id: compiler-performance
title: "Compiler performance"
---
Quill will probably make the slow scala compiler even slower, since a lot of additional `Parsing`, `Typechecking`, `Implicit resolution` works introduced to expand a Query.

Following tips may help improving compilation time.

## Use `-Yprofile-trace` scalac options.
With `-Yprofile-trace` option, a chrome trace file will be produced after compilation.
It will help figure out what slowing down the compiler.

Note, this option need some tweak if you are running on java 9 or newer version.

## Split large module into multiple submodules
Since scalac is not fully parallelized, split into independent submodules can significantly reduce build time on multi-core cpu.

## Define decoder/encoder directly instead of `MappedEncoding`

`MappedEncoding` introduce more implicit resolutions, which may slow down compiler.

It is possible to define instance directly.

```scala
case class FooId(id: Long)
implicit val fooIdEncoder: Encoder[FooId] = mappedEncoder(MappedEncoding[FooId, Long](_.id), longEncoder)
implicit val fooIdDecoder: Decoder[FooId] = mappedDecoder(MappedEncoding[Long, FooId](FooId(_)), longDecoder)
```

## Share `QueryMeta` instance

`QueryMeta` generation requires `Decoder` resolution, tree generation, typechecking, etc which can be very slow.

`QueryMeta` is not shared by default, so define shared `QueryMeta` instance may reduce build time.

```scala
val ctx = SqlMirrorContext(MirrorIdiom, Literal)

// Prevent using default macro generated query meta instance.
// Use `_` instead of `*` if `-Xsource:3` not enabled.
import ctx.{ materializeQueryMeta => *, * }

// Instance type must not be specified here, otherwise it will become dynamic query.
implicit val orderQueryMeta = ctx.materializeQueryMeta[Order]

ctx.run {
query[Order]
}
```
Note, to use [`-Xsource:3`](https://github.com/scala/scala/pull/10439) scalac options, `-Xmigration` or `-Wconf:cat=scala3-migration:w` is required.

Otherwise, it will not compile due to lack of explicit type of implicit definition.
Loading

0 comments on commit 0545e0f

Please sign in to comment.