Skip to content

Commit

Permalink
Tag snapshot input for association with dep files
Browse files Browse the repository at this point in the history
Summary:
[Doc](https://docs.google.com/document/d/1-zhGPkmt3I2os-kcIaFk9SvT6odt2AJWswSY-J_6AWs/edit?usp=sharing)

### Context
We are exploring the integration of the Kotlin Incremental Compiler into Buck for the incremental compilation of Kotlin source files. The goal is to improve build speed by only recompiling modified source files within a target, rather than rebuilding the entire target as is currently done.

### Problem
With the incremental compiler enabled, we observed a 14% decrease in LOCAL_DEP_FILE action execution type, compensated by a 10% increase in LOCAL_WORKER execution type ([scuba](https://fburl.com/scuba/buck2_actions_user/amr07tu2)).

### Solution
It was discovered that the new library artifact, classpath snapshots (added in D62533759), used by the compiler were not tagged for consideration by dep_files (see [doc](https://www.internalfb.com/intern/staticdocs/buck2/docs/rule_authors/dep_files/)). As a result, every change in a dependency that resulted in a new jar, even if the change itself was filtered out by dep_files, caused a rebuild of the target since the snapshot of the jar was always evaluated as a change in the input.

### This diff
Tags snapshot inputs for association with dep files.

Reviewed By: IanChilds

Differential Revision: D66533725

fbshipit-source-id: 795e793e21f2bfbf71abe0e195d075a2e3ad1586
  • Loading branch information
Iveta Jurčíková authored and facebook-github-bot committed Nov 27, 2024
1 parent 337e8e1 commit ea35f52
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion prelude/jvm/cd_jar_creator_util.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,11 @@ def encode_base_jar_command(
compiling_classpath = classpath_jars_tag.tag_artifacts(
[dep.abi for dep in compiling_deps_list],
)
compiling_classpath_snapshot = {dep.abi: dep.abi_jar_snapshot or "" for dep in compiling_deps_list} if is_incremental else {}

# The snapshot inputs are tagged for association with dep_files, but they are not marked as used,
# as they serve the incremental compiler's internal needs,
# which are utilized after the build system has determined whether a rebuild is necessary.
compiling_classpath_snapshot = classpath_jars_tag.tag_artifacts({dep.abi: dep.abi_jar_snapshot or "" for dep in compiling_deps_list}) if is_incremental else {}

build_target_value = struct(
fullyQualifiedName = qualified_name,
Expand Down

0 comments on commit ea35f52

Please sign in to comment.