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

[Build] Make ThirdPartyAudit task uptodate more effective #118723

Merged

Conversation

breskeby
Copy link
Contributor

@breskeby breskeby commented Dec 14, 2024

We should basically be able to skip the third party dependency audit tasks if no third party dependency has changed.

Filtering out the project dependencies allows way better uptodate and caching behaviour. We are only interested in thirdparty libs anyhow in this context.

A positive side effect of the reduced class path is a quicker execution of the task

@breskeby breskeby added :Delivery/Build Build or test infrastructure Team:Delivery Meta label for Delivery team labels Dec 14, 2024
@breskeby breskeby self-assigned this Dec 14, 2024
@breskeby breskeby added v9.0.0 v8.17.1 v8.18.0 auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) labels Dec 14, 2024
@breskeby breskeby force-pushed the make-thirdpartycheckinputseffective branch from 78d9dfd to 51e229e Compare December 14, 2024 22:43
@breskeby
Copy link
Contributor Author

@breskeby breskeby changed the title [Build]Make thirdparty audit tasks uptodate more effective [Build] Make thirdparty audit tasks uptodate more effective Dec 14, 2024
@breskeby breskeby marked this pull request as ready for review December 14, 2024 23:17
@breskeby breskeby requested a review from a team as a code owner December 14, 2024 23:17
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-delivery (Team:Delivery)

@breskeby breskeby changed the title [Build] Make thirdparty audit tasks uptodate more effective [Build] Make ThirdPartyAudit task uptodate more effective Dec 15, 2024
* project dependencies that are not shadowed jars.
* Basically a thirdparty only view of the dependency tree.
*/
public static FileCollection thirdPartyDependenciesView(Configuration configuration) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't calling this effectively trigger dependency resolution? I think we might be implicitly relying on lazy task configuration to not eagerly resolve dependencies when we shouldn't but I think we might need to wrap this in a Provider or something to be totally proper.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The artifactview handling itself is lazy. But there was indeed an oversight in the util method implementation where I resolved the provider eagerly and the dependency infos (not the artifacts) have been resolved eagerly. fixed this here: 5f507b0

now those configurations are really only resolved at task graph calculation time.

One issue is that I have configuration cache enabled by default for testing locally and this makes dependency resolution timings differ from the normal way that makes it easier to oversee this 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

But doesn't the call to getFiles() immediately trigger resolution? Where's the lazy bit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mark-vieira getFiles only gives you back file collection that is lazy as configuration itself is. the resolution is kicking only in when that file collection is resolved. like a configuration is implementing filecollection too. you might mix that up with FileCollection#getFiles like Configuration#getFiles returning a Set.

Trust me bro...

And in case you don't ....
I double checked manually by throwing in exception using the beforeResolve hook and that shows how only the task graph building triggered the resolution: https://gradle-enterprise.elastic.co/s/n6igninpsi3m4/failure?expanded-stacktrace=WyIwIl0&focused-stack-frame=0-28#1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need to think if there is a way we can enforce failing builds or at least have a regular check running to ensure we don't resolve anything too early. One option might be to verify https://gradle-enterprise.elastic.co/s/6bqzp2o7mq6k2/performance/dependency-resolution#dependency-resolution-configuration-user-initiated programatically somehow.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mark-vieira getFiles only gives you back file collection that is lazy as configuration itself is. the resolution is kicking only in when that file collection is resolved. like a configuration is implementing filecollection too. you might mix that up with FileCollection#getFiles like Configuration#getFiles returning a Set.

Ah, gotcha. That makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

One option might be to verify https://gradle-enterprise.elastic.co/s/6bqzp2o7mq6k2/performance/dependency-resolution#dependency-resolution-configuration-user-initiated programatically somehow.

Indeed. I wonder if that's detected during the built itself, or just inferred based on resolution event data after the fact.

Filtering out the project dependencies allows way better uptodate and caching behaviour.
We are only interested in thirdparty libs anyhow in this context.
@breskeby breskeby force-pushed the make-thirdpartycheckinputseffective branch from fade149 to a2db848 Compare December 17, 2024 00:21
we do not want to do any dependency resolution preemptively
@breskeby breskeby force-pushed the make-thirdpartycheckinputseffective branch from a2db848 to 5f507b0 Compare December 17, 2024 00:23
@breskeby breskeby requested a review from mark-vieira December 17, 2024 00:27
@elasticsearchmachine elasticsearchmachine merged commit d118cbf into elastic:main Dec 18, 2024
17 checks passed
@breskeby breskeby deleted the make-thirdpartycheckinputseffective branch December 18, 2024 08:22
rjernst pushed a commit to rjernst/elasticsearch that referenced this pull request Dec 18, 2024
…8723)

We should basically be able to skip the third party dependency audit
tasks if no third party dependency has changed.

Filtering out the project dependencies allows way better uptodate and
caching behaviour. We are only interested in thirdparty libs anyhow in
this context.

A positive side effect of the reduced class path is a quicker execution
of the task
navarone-feekery pushed a commit to navarone-feekery/elasticsearch that referenced this pull request Dec 26, 2024
…8723)

We should basically be able to skip the third party dependency audit
tasks if no third party dependency has changed.

Filtering out the project dependencies allows way better uptodate and
caching behaviour. We are only interested in thirdparty libs anyhow in
this context.

A positive side effect of the reduced class path is a quicker execution
of the task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Delivery/Build Build or test infrastructure >non-issue Team:Delivery Meta label for Delivery team v8.17.1 v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants