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

Fix analysis time regression with Bzlmod lockfile #19970

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,46 @@

package com.google.devtools.build.lib.bazel.bzlmod;

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableTable;
import com.google.devtools.build.lib.events.ExtendedEventHandler.Postable;

/**
* After resolving bazel module this event is sent from {@link BazelDepGraphFunction} holding the
* lockfile value with module updates, and the module extension usages. It will be received in
* {@link BazelLockFileModule} to be used to update the lockfile content
*
* <p>Instances of this class are retained in Skyframe nodes and subject to frequent {@link
* java.util.Set}-based deduplication. As such, it <b>must</b> have a cheap implementation of {@link
* #hashCode()} and {@link #equals(Object)}. It currently uses reference equality since the logic
* that creates instances of this class already ensures that there is only one instance per build.
*/
@AutoValue
public abstract class BazelModuleResolutionEvent implements Postable {
public final class BazelModuleResolutionEvent implements Postable {

private final BazelLockFileValue lockfileValue;
private final ImmutableTable<ModuleExtensionId, ModuleKey, ModuleExtensionUsage>
extensionUsagesById;

private BazelModuleResolutionEvent(
BazelLockFileValue lockfileValue,
ImmutableTable<ModuleExtensionId, ModuleKey, ModuleExtensionUsage> extensionUsagesById) {
this.lockfileValue = lockfileValue;
this.extensionUsagesById = extensionUsagesById;
}

public static BazelModuleResolutionEvent create(
BazelLockFileValue lockFileValue,
ImmutableTable<ModuleExtensionId, ModuleKey, ModuleExtensionUsage> extensionUsagesById) {
return new AutoValue_BazelModuleResolutionEvent(lockFileValue, extensionUsagesById);
return new BazelModuleResolutionEvent(lockFileValue, extensionUsagesById);
}

public abstract BazelLockFileValue getLockfileValue();
public BazelLockFileValue getLockfileValue() {
return lockfileValue;
}

public abstract ImmutableTable<ModuleExtensionId, ModuleKey, ModuleExtensionUsage>
getExtensionUsagesById();
public ImmutableTable<ModuleExtensionId, ModuleKey, ModuleExtensionUsage>
getExtensionUsagesById() {
return extensionUsagesById;
}

@Override
public boolean storeForReplay() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,53 @@

package com.google.devtools.build.lib.bazel.bzlmod;

import com.google.auto.value.AutoValue;
import com.google.devtools.build.lib.events.ExtendedEventHandler.Postable;

/**
* After evaluating any module extension this event is sent from {@link SingleExtensionEvalFunction}
* holding the extension id and the resolution data LockFileModuleExtension. It will be received in
* {@link BazelLockFileModule} to be used to update the lockfile content
* {@link BazelLockFileModule} to be used to update the lockfile content.
*
* <p>Instances of this class are retained in Skyframe nodes and subject to frequent {@link
* java.util.Set}-based deduplication. As such, it <b>must</b> have a cheap implementation of {@link
* #hashCode()} and {@link #equals(Object)}. It currently uses reference equality since the logic
* that creates instances of this class already ensures that there is only one instance per
* extension id.
*/
@AutoValue
public abstract class ModuleExtensionResolutionEvent implements Postable {
public final class ModuleExtensionResolutionEvent implements Postable {

private final ModuleExtensionId extensionId;
private final ModuleExtensionEvalFactors extensionFactors;
private final LockFileModuleExtension moduleExtension;

private ModuleExtensionResolutionEvent(
ModuleExtensionId extensionId,
ModuleExtensionEvalFactors extensionFactors,
LockFileModuleExtension moduleExtension) {
this.extensionId = extensionId;
this.extensionFactors = extensionFactors;
this.moduleExtension = moduleExtension;
}

public static ModuleExtensionResolutionEvent create(
ModuleExtensionId extensionId,
ModuleExtensionEvalFactors extensionFactors,
LockFileModuleExtension lockfileModuleExtension) {
return new AutoValue_ModuleExtensionResolutionEvent(
return new ModuleExtensionResolutionEvent(
extensionId, extensionFactors, lockfileModuleExtension);
}

public abstract ModuleExtensionId getExtensionId();
public ModuleExtensionId getExtensionId() {
return extensionId;
}

public abstract ModuleExtensionEvalFactors getExtensionFactors();
public ModuleExtensionEvalFactors getExtensionFactors() {
return extensionFactors;
}

public abstract LockFileModuleExtension getModuleExtension();
public LockFileModuleExtension getModuleExtension() {
return moduleExtension;
}

@Override
public boolean storeForReplay() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public interface Reportable {
*
* <p>This method is not relevant for events which do not originate from {@link
* com.google.devtools.build.skyframe.SkyFunction} evaluation.
*
* <p>Classes returning {@code true} should have cheap {@link Object#hashCode()} and {@link
* Object#equals(Object)} implementations.
*/
default boolean storeForReplay() {
return false;
Expand Down
Loading