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

Reland "Also path map transitive header jar paths with direct classpath optimization" #21401

Closed
wants to merge 2 commits into from

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented Feb 17, 2024

Rollforward of fd196bf, which was rolled back in f5d76b1.

The analysis-time memory regression (newly retained NestedSet instances) has been resolved separately in 31fae9e. The execution-time memory regression (unconditionally flattened NestedSets) is now only incurred with path mapping enabled.

Original description:

JavaHeaderCompileAction can apply an optimization where it compiles the source files only against direct dependencies, making use of the fact that Turbine includes sufficient information about transitive dependencies into the direct header jars in a special directory.

In order to ensure that downstream consumers of header compilation action can use its .jdeps file regardless of which of these actions actually uses path mapping, all such paths to transitive jars have to be unmapped.

With this commit, actions can declare additional artifacts whose paths they want to apply path mapping to. By always passing all transitive jars into the path mapper, even when only the direct jars are inputs to the action, the transitive header jar paths can be unmapped and stripped path collisions between them correctly result in a noop PathMapper being used for the current action.

@fmeum fmeum marked this pull request as ready for review February 17, 2024 18:14
@fmeum fmeum requested review from a team and lberki as code owners February 17, 2024 18:14
@fmeum fmeum requested review from katre and hvadehra and removed request for a team, lberki and katre February 17, 2024 18:14
@github-actions github-actions bot added team-Performance Issues for Performance teams team-Configurability platforms, toolchains, cquery, select(), config transitions team-Rules-Java Issues for Java rules awaiting-review PR is awaiting review from an assigned reviewer labels Feb 17, 2024
@fmeum
Copy link
Collaborator Author

fmeum commented Feb 17, 2024

FYI @aranguyen

@fmeum fmeum self-assigned this Feb 17, 2024
@hvadehra
Copy link
Member

LGTM, and I can confirm most of the regression is gone (other than the small amount caused by the new field).

However since @aranguyen has an alternative change in progress, I'd like them to confirm which way they'd like to proceed with.

@aranguyen
Copy link
Contributor

@hvadehra I spoke with both @fmeum and @cushon about both fixes and if this updated fix does not have any serious regression, let's go ahead with this one because this makes sure the .jdeps files will only contained unmapped paths and not mixed paths. The other alternative fixing only getReducedClassPath won't be needed if the .jdeps files do not contain mix paths.

@fmeum
Copy link
Collaborator Author

fmeum commented Feb 20, 2024

@bazel-io fork 7.1.0

@aranguyen aranguyen added the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Feb 20, 2024
@github-actions github-actions bot removed awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally awaiting-review PR is awaiting review from an assigned reviewer labels Feb 21, 2024
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Feb 21, 2024
…th optimization"

Rollforward of fd196bf, which was rolled back in f5d76b1.

The analysis-time memory regression (newly retained `NestedSet` instances) has been resolved separately in 31fae9e. The execution-time memory regression (unconditionally flattened `NestedSet`s) is now only incurred with path mapping enabled.

Original description:

`JavaHeaderCompileAction` can apply an optimization where it compiles the source files only against direct dependencies, making use of the fact that Turbine includes sufficient information about transitive dependencies into the direct header jars in a special directory.

In order to ensure that downstream consumers of header compilation action can use its `.jdeps` file regardless of which of these actions actually uses path mapping, all such paths to transitive jars have to be unmapped.

With this commit, actions can declare additional artifacts whose paths they want to apply path mapping to. By always passing all transitive jars into the path mapper, even when only the direct jars are inputs to the action, the transitive header jar paths can be unmapped and stripped path collisions between them correctly result in a noop `PathMapper` being used for the current action.

Closes bazelbuild#21401.

PiperOrigin-RevId: 609010786
Change-Id: I0d9ea5b11430ee40be74fe582af84fedaa52ade6
@fmeum fmeum deleted the 19872-roll-forward branch February 21, 2024 17:10
github-merge-queue bot pushed a commit that referenced this pull request Feb 21, 2024
… classpath optimization" (#21458)

Rollforward of fd196bf, which was
rolled back in f5d76b1.

The analysis-time memory regression (newly retained `NestedSet`
instances) has been resolved separately in
31fae9e. The execution-time memory
regression (unconditionally flattened `NestedSet`s) is now only incurred
with path mapping enabled.

Original description:

`JavaHeaderCompileAction` can apply an optimization where it compiles
the source files only against direct dependencies, making use of the
fact that Turbine includes sufficient information about transitive
dependencies into the direct header jars in a special directory.

In order to ensure that downstream consumers of header compilation
action can use its `.jdeps` file regardless of which of these actions
actually uses path mapping, all such paths to transitive jars have to be
unmapped.

With this commit, actions can declare additional artifacts whose paths
they want to apply path mapping to. By always passing all transitive
jars into the path mapper, even when only the direct jars are inputs to
the action, the transitive header jar paths can be unmapped and stripped
path collisions between them correctly result in a noop `PathMapper`
being used for the current action.

Closes #21401.

Commit
74fe669

PiperOrigin-RevId: 609010786
Change-Id: I0d9ea5b11430ee40be74fe582af84fedaa52ade6

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
@iancha1992
Copy link
Member

The changes in this PR have been included in Bazel 7.1.0 RC1. Please test out the release candidate and report any issues as soon as possible. If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=last_rc.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Configurability platforms, toolchains, cquery, select(), config transitions team-Performance Issues for Performance teams team-Rules-Java Issues for Java rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants