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

Modularize :configuration-cache #29207

Merged
merged 16 commits into from
May 21, 2024
Merged

Modularize :configuration-cache #29207

merged 16 commits into from
May 21, 2024

Conversation

bamboo
Copy link
Member

@bamboo bamboo commented May 17, 2024

Initially by extracting three modules:

  • :configuration-problems-base: base utilities for reporting configuration problems with structured messages and property traces
  • :object-serialization: core configuration cache serialization api and implementation but no codecs
  • :java-language-extensions-kt: Java/Kotlin stdlib extensions shared by all modules

This is just the first step, subsequent PRs will detangle and move more code from :configuration-cache into :object-serialization and rename all moved packages to match the new structure.

Context

:configuration-cache is currently one of the largest Gradle modules. It is time to modularize it to reduce compilation times and cognitive overhead.

Reviewing cheatsheet

Before merging the PR, comments starting with

  • ❌ ❓must be fixed
  • 🤔 💅 should be fixed
  • 💭 may be fixed
  • 🎉 celebrate happy things

@bamboo bamboo added a:chore Minor issue without significant impact re:platformization Tracks work related to the platformization effort labels May 17, 2024
@bamboo bamboo added this to the 8.9 RC1 milestone May 17, 2024
@bamboo bamboo self-assigned this May 17, 2024
@bamboo bamboo force-pushed the bamboo/cc/modularize/i branch 2 times, most recently from 5c67a69 to 93425a0 Compare May 20, 2024 12:43
@gitstream-cm gitstream-cm bot removed the a:chore Minor issue without significant impact label May 20, 2024
Copy link
Member

@abstratt abstratt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good step in the right direction.

Only actual changes I could see were the introcdution of a base ProblemsListener implementation (AbstractProblemsListener), and introduction of a sealed class hierarchy for IsolateOwner implementations.

suspend fun WriteContext.writeStateOf(bean: Any)
dependencies {
api(libs.futureKotlin("stdlib"))
implementation(projects.javaLanguageExtensions)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I see the parallel between this new module and the existing java-language-extensions, I have no issue with the new name. Actually, I think this module is a much better described as "stdlib-extensions" than the one for Java, as the latter actually introduces things that go way beyond providing general purpose extensions to the Java library.

It seems we are consuming java-language-extensions just to get access to Cast. That is fine, more of a problem with that module's purpose than with this one (and that module's scope is already an improvement over recent past).

api(projects.serviceProvider)
api(projects.configurationProblemsBase)
api(project(":base-services"))
api(project(":build-operations"))
// TODO - it might be good to allow projects to contribute state to save and restore, rather than have this project know about everything
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this refers to the design you mentioned we want to pursue, which would de-invert the dependencies.

@@ -98,56 +89,10 @@ class DefaultWriteContext(
}


internal
class LoggingTracer(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"deleted" classes here were moved to their own files

import kotlin.coroutines.Continuation
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.coroutineContext
import kotlin.coroutines.startCoroutine
import kotlin.coroutines.suspendCoroutine


internal
fun <T> singleton(value: T): Codec<T> =
SingletonCodec(value)


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functions were moved to platforms/core-configuration/configuration-cache/src/main/kotlin/org/gradle/configurationcache/serialization/Unsupported.kt

@@ -275,104 +219,34 @@ suspend fun <K, V, T : MutableMap<K, V>> ReadContext.readMapEntriesInto(items: T
}


internal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extension functions moved to platforms/core-configuration/configuration-cache/src/main/kotlin/org/gradle/configurationcache/serialization/ClassPathEncodingExtensions.kt

@@ -110,39 +111,12 @@ interface IsolateContext {
}


sealed class IsolateOwner {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to own file and made part of a new sealed class hierachy

@@ -469,7 +474,7 @@ class ConfigurationCacheState(

build.createProjects()

initProjectProvider(build::getProject)
setSingletonProperty<ProjectProvider>(build::getProject)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to decouple WriteContext from ProjectInternal

@bamboo bamboo marked this pull request as ready for review May 20, 2024 15:10
@bamboo bamboo requested review from a team as code owners May 20, 2024 15:10
@bamboo bamboo requested review from jvandort and mlopatkin and removed request for a team May 20, 2024 15:10
@bamboo bamboo added this pull request to the merge queue May 20, 2024
@bot-gradle
Copy link
Collaborator

The merge queue build has failed. Click here to see all failures.

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 20, 2024
@bamboo bamboo force-pushed the bamboo/cc/modularize/i branch 2 times, most recently from 72ccc61 to 761e557 Compare May 20, 2024 20:55
@bamboo bamboo added this pull request to the merge queue May 20, 2024
@bot-gradle
Copy link
Collaborator

The merge queue build has failed. Click here to see all failures.

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 20, 2024
@bamboo bamboo force-pushed the bamboo/cc/modularize/i branch 2 times, most recently from a8e067e to a5c6b2c Compare May 21, 2024 17:16
@bamboo
Copy link
Member Author

bamboo commented May 21, 2024

@bot-gradle test AST

@gradle gradle deleted a comment from bamboo May 21, 2024
@gradle gradle deleted a comment from bamboo May 21, 2024
@bot-gradle
Copy link
Collaborator

I've triggered the following builds for you. Click here to see all build failures.

bamboo added 15 commits May 21, 2024 16:09
Initially by extracting three modules:
- configuration-problems-base: base utilities for reporting configuration
  problems with structured messages and property traces
- object-graph-serialization: aimed at holding the core configuration cache
  serialization implementation but currently only containing the detangled code
- kotlin-language-extensions: holding the Kotlin extensions shared by all
  modules

This is just the first step, subsequent commits will detangle and move more code
from `:configuration-cache` into `:object-graph-serialization` and rename all
moved packages to match the new structure.
Because it is used by `DefaultProblemsFactory` from
`:configuration-problems-base`.
To `:object-graph-serialization`.
With a potential impact to `gcc2speedscope` since generated type names are no
longer unpacked to avoid a dependency on `:base-services`.
@bamboo bamboo added this pull request to the merge queue May 21, 2024
@bamboo bamboo removed this pull request from the merge queue due to a manual request May 21, 2024
Since the `kotlin` word in module names is reserved for Kotlin DSL
modules.
@bamboo bamboo added this pull request to the merge queue May 21, 2024
Merged via the queue into master with commit f052e10 May 21, 2024
26 checks passed
@bamboo bamboo deleted the bamboo/cc/modularize/i branch May 21, 2024 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
re:platformization Tracks work related to the platformization effort
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants