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

Acquire project locks in component state #29193

Merged
merged 2 commits into from
May 31, 2024

Conversation

jvandort
Copy link
Member

Previously, project locks were not acquired in the component graph state when project state was being accessed. This led to some situations where data races could occur.

In many cases, when dependency resolution is properly declared, this does not matter, as walking the task dependency graph is single-threaded, and therefore these caches would be realized without any data races possible. However, when the parallel flag is enabled, for undeclared dependency resolution, or other potential edge cases, it was still possible to get data races when multiple resolutions both access project state simultaneously.

This change makes sure that all project state is wrapped in the proper locks before it is accessed.

This should also clear the way to making task graph calculation multithreaded, as resolving configurations during task dependency graph calculation is currently a major bottleneck of configuration-time.

Context

Contributor Checklist

  • Review Contribution Guidelines.
  • Make sure that all commits are signed off to indicate that you agree to the terms of Developer Certificate of Origin.
  • Make sure all contributed code can be distributed under the terms of the Apache License 2.0, e.g. the code was written by yourself or the original code is licensed under a license compatible to Apache License 2.0.
  • Check "Allow edit from maintainers" option in pull request so that additional changes can be pushed by Gradle team.
  • Provide integration tests (under <subproject>/src/integTest) to verify changes from a user perspective.
  • Provide unit tests (under <subproject>/src/test) to verify logic.
  • Update User Guide, DSL Reference, and Javadoc for public-facing changes.
  • Ensure that tests pass sanity check: ./gradlew sanityCheck.
  • Ensure that tests pass locally: ./gradlew <changed-subproject>:quickTest.

Reviewing cheatsheet

Before merging the PR, comments starting with

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

@jvandort jvandort self-assigned this May 17, 2024
@jvandort jvandort added this to the 8.9 RC1 milestone May 17, 2024
@jvandort
Copy link
Member Author

@bot-gradle test apt

@bot-gradle
Copy link
Collaborator

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

@jvandort
Copy link
Member Author

@bot-gradle test this

@bot-gradle
Copy link
Collaborator

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

@jvandort jvandort marked this pull request as ready for review May 17, 2024 02:04
@jvandort jvandort requested review from a team as code owners May 17, 2024 02:04
@jvandort jvandort requested review from ghale, bamboo, abstratt and big-guy and removed request for a team and ghale May 17, 2024 02:04
@jvandort jvandort force-pushed the jvandort/dm/move-stateful-logic-from-local-metadata-to-state branch from 4491d91 to 1ac7e5e Compare May 22, 2024 16:01
@jvandort jvandort marked this pull request as draft May 22, 2024 16:17
@jvandort jvandort force-pushed the jvandort/dm/acquire-project-locks-in-component-state branch from ea565aa to 548c896 Compare May 22, 2024 19:05
@jvandort jvandort marked this pull request as ready for review May 22, 2024 19:05
Base automatically changed from jvandort/dm/move-stateful-logic-from-local-metadata-to-state to master May 22, 2024 20:43
@jvandort jvandort requested a review from adammurdoch May 22, 2024 20:51
Previously, project locks were not acquired in the component graph state when project state was being
accessed. This led to some situations where data races could occur.

In many cases, when dependency resolution is properly declared, this does not matter, as walking the
task dependency graph is single-threaded, and therefore these caches would be realized without any
data races possible. However, when the parallel flag is enabled, for undeclared dependency resolution, or
other potential edge cases, it was still possible to get data races when multiple resolutions both access
project state simultaneously.

This change makes sure that all project state is wrapped in the proper locks before it is accessed.

This should also clear the way to making task graph calculation multithreaded, as resolving configurations
during task dependency graph calculation is currently a major bottleneck of configuration-time.
@jvandort jvandort force-pushed the jvandort/dm/acquire-project-locks-in-component-state branch from 548c896 to 6c71b73 Compare May 31, 2024 20:25
@jvandort jvandort added this pull request to the merge queue May 31, 2024
Merged via the queue into master with commit c2d3cb3 May 31, 2024
20 of 22 checks passed
@jvandort jvandort deleted the jvandort/dm/acquire-project-locks-in-component-state branch May 31, 2024 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants