Skip to content

Conversation

maximiln
Copy link
Contributor

@maximiln maximiln commented Sep 15, 2025

Separate Source and Test Input Checksums for Enhanced Build Incrementality #380

  • Add separate checksums for source and test inputs for enhanced build incrementality
  • Increment cache version to v1.2 (breaking change)
  • Create AbstractInputAnalyzer base class to eliminate code duplication
  • Refactor SrcInputAnalyzer and TestInputAnalyzer to extend base class
  • Reduce code duplication by ~300 lines (60% reduction)
  • Add comprehensive tests for dual checksum functionality

Enhanced build logic:

  • Source-only changes: rebuild only if source checksum differs
  • Test-only changes: rebuild only if test checksum differs OR source changes
  • Both changed: full rebuild required
  • Neither changed: use cached results

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

…se class refactoring

- Add separate checksums for source and test inputs for enhanced build incrementality
- Implement web-path compatible cache key format: `{source_checksum}-{test_checksum}`
- Increment cache version to v1.2 (breaking change)
- Create AbstractInputAnalyzer base class to eliminate code duplication
- Refactor SrcInputAnalyzer and TestInputAnalyzer to extend base class
- Reduce code duplication by ~300 lines (60% reduction)
- Add comprehensive tests for dual checksum functionality

Enhanced build logic:
- Source-only changes: rebuild only if source checksum differs
- Test-only changes: rebuild only if test checksum differs OR source changes
- Both changed: full rebuild required
- Neither changed: use cached results
@maximiln maximiln changed the title #380 feat: implement dual checksum calculation with abstract base cla… #380 feat: implement dual checksum calculation Sep 15, 2025

// Add all input files to the hash
for (Path inputFile : inputFiles) {
checksum.update(inputFile.toString().getBytes());
Copy link
Contributor

Choose a reason for hiding this comment

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

getBytes() is using the platform's default charset, for portability between win/linux it is better to set encoding.

String sourceChecksum = combinedChecksum.substring(0, separatorIndex);
String testChecksum = combinedChecksum.substring(separatorIndex + 1);

return new String[] {sourceChecksum, testChecksum};
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: split

if (sourceChanged && testChanged) {
return RebuildType.FULL_REBUILD;
} else if (sourceChanged) {
return RebuildType.SOURCE_REBUILD;
Copy link
Contributor

Choose a reason for hiding this comment

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

If the source changes, then the tests should be rebuilt too. For example, they might stop compiling.

final SortedMap<String, String> pluginDependenciesChecksum = getMutablePluginDependencies();
final String sourceChecksum = dualCalculator.calculateSourceChecksum();
final String testChecksum = dualCalculator.calculateTestChecksum();
final String combinedChecksum = dualCalculator.calculateDualChecksum();
Copy link
Contributor

Choose a reason for hiding this comment

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

this will recalculate again sourceChecksum and testChecksum - could be calculated once

final HashChecksum checksum = config.getHashFactory().createChecksum(count);
// Create digest items for the new dual checksum approach
final List<DigestItem> items = new ArrayList<>();
final HashChecksum checksum = config.getHashFactory().createChecksum(3);
Copy link
Contributor

Choose a reason for hiding this comment

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

what is 3 in createChecksum(3)?

DigestItem fileDigest = DigestUtils.file(checksum, baseDirPath, file);
items.add(fileDigest);
if (compareWithBaseline) {
sourcesMatched &= checkItemMatchesBaseline(baselineHolder.get(), fileDigest);
Copy link
Contributor

Choose a reason for hiding this comment

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

that was a diff report (compare 2 buildinfos from different sources to find mismatches). is it moved or deprecated?

@maximiln maximiln changed the title #380 feat: implement dual checksum calculation [WIP] #380 feat: implement dual checksum calculation Sep 16, 2025
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.

3 participants