Skip to content

Commit d677e41

Browse files
krallinfacebook-github-bot
authored andcommittedSep 12, 2022
buck2: create_unhashed_outputs: do cheap checks before expensive ones
Summary: Its not very clear to me why we need this, but it looks like checking the count of outputs on an artifact can take a while in aggregate. I guess this makes sense since we can have large artifact groups as other-outputs? Anyway, it's cheaper to check whether the artifact is indeed a default output (which we care about) before attempting to iterate than it is to do the reverse, so we might as well. Reviewed By: nshipilov Differential Revision: D39425072 fbshipit-source-id: 1897f16d60ea80583a227617d423823d0fe8af1d
1 parent 6b53bc2 commit d677e41

File tree

1 file changed

+15
-15
lines changed
  • buck2_server_commands/src/commands/build

1 file changed

+15
-15
lines changed
 

‎buck2_server_commands/src/commands/build/mod.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -287,25 +287,25 @@ fn create_unhashed_outputs(
287287
// The following IndexMap will contain a key of the unhashed/symlink path and values of all the hashed locations that map to the unhashed location.
288288
let mut unhashed_to_hashed: IndexMap<AbsPathBuf, HashSet<AbsPathBuf>> = IndexMap::new();
289289
for provider_artifact in provider_artifacts {
290+
if !matches!(provider_artifact.provider_type, BuildProviderType::Default) {
291+
continue;
292+
}
293+
290294
match provider_artifact.values.iter().exactly_one() {
291-
Ok((artifact, _)) => match provider_artifact.provider_type {
292-
BuildProviderType::Default => match artifact.as_parts().0 {
293-
BaseArtifactKind::Build(build) => {
294-
let unhashed_path =
295-
artifact_fs.retrieve_unhashed_location(build.get_path());
296-
let path = artifact_fs.resolve(artifact.get_path())?;
297-
let abs_unhashed_path = fs.resolve(&unhashed_path);
298-
let entry = unhashed_to_hashed
299-
.entry(abs_unhashed_path)
300-
.or_insert_with(HashSet::new);
301-
entry.insert(fs.resolve(&path));
302-
}
303-
_ => {}
304-
},
295+
Ok((artifact, _)) => match artifact.as_parts().0 {
296+
BaseArtifactKind::Build(build) => {
297+
let unhashed_path = artifact_fs.retrieve_unhashed_location(build.get_path());
298+
let path = artifact_fs.resolve(artifact.get_path())?;
299+
let abs_unhashed_path = fs.resolve(&unhashed_path);
300+
let entry = unhashed_to_hashed
301+
.entry(abs_unhashed_path)
302+
.or_insert_with(HashSet::new);
303+
entry.insert(fs.resolve(&path));
304+
}
305305
_ => {}
306306
},
307307
Err(_) => {}
308-
}
308+
};
309309
}
310310
// The IndexMap is used now to determine if and what conflicts exist where multiple hashed artifact locations
311311
// all want a symlink to the same unhashed artifact location and deal with them accordingly.

0 commit comments

Comments
 (0)
Please sign in to comment.