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

Optimise IncrementalCacheManager.java #504

Merged
merged 1 commit into from
Dec 22, 2024
Merged
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 @@ -56,7 +56,7 @@ public class IncrementalCacheManager {

// If we make breaking changes to the format of the cache, increment this value. This prevents
// builds failing for users between versions if they do not perform a clean install first.
private static final String SPEC_VERSION = "1.0";
private static final String SPEC_VERSION = "1.1";
private static final Logger log = LoggerFactory.getLogger(IncrementalCacheManager.class);

private final ConcurrentExecutor concurrentExecutor;
Expand Down Expand Up @@ -111,25 +111,6 @@ public Collection<Path> determineSourcesToCompile(
return flattenSourceProtoFiles(listing.getCompilableSources());
}

var filesDeletedSinceLastBuild = !previousBuildCache.getSources().keySet()
.stream()
.allMatch(nextBuildCache.getSources().keySet()::contains);

// If any sources were deleted, we should rebuild everything, as those files being deleted may
// have caused a compilation failure.
if (filesDeletedSinceLastBuild) {
log.info("Detected that source files have been deleted, all sources will be recompiled");
return flattenSourceProtoFiles(listing.getCompilableSources());
}

// For now, let's be more aggressive and force a full rebuild if any files change.
// This prevents the risk of missing changes such as imports changing in sibling files,
// which we will not force a full rebuild for. We might be able to build a DAG in the
// future to track these and be able to uncomment the following snippet instead.
//return nextBuildCache.getSources().keySet()
// .stream()
// .filter(isSourceFileDifferent(previousBuildCache, nextBuildCache))
// .collect(Collectors.toUnmodifiableSet());
var sourceFilesChanged = nextBuildCache.getSources().keySet()
.stream()
.filter(isSourceFileDifferent(previousBuildCache, nextBuildCache))
Expand All @@ -141,6 +122,7 @@ public Collection<Path> determineSourcesToCompile(
return flattenSourceProtoFiles(listing.getCompilableSources());
}

log.info("Detected no changes to sources or dependencies since the previous build.");
return List.of();
}

Expand Down
Loading