Skip to content

Commit

Permalink
bazel sync: support --loading_phase_threads instead of using Skyframe…
Browse files Browse the repository at this point in the history
…Executor.DEFAULT_THREAD_COUNT

The number of threads during the loading (i.e., the only thing that bazel sync does)
is an important tuneable to obtain good performance and there is no "one size fits
all" for this. So make `bazel sync` honor the already existing flag.

Related to bazelbuild#6502.

Change-Id: Iaf38315b4a6640c7011fee99da235d7c9bbba6b1
PiperOrigin-RevId: 222051926
  • Loading branch information
aehlig authored and Copybara-Service committed Nov 19, 2018
1 parent 511fe9b commit 828b1fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/google/devtools/build/lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ java_library(
":events",
":exitcode-external",
":keep-going-option",
":loading-phase-threads-option",
":packages-internal",
":runtime",
":util",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.google.devtools.build.lib.runtime.Command;
import com.google.devtools.build.lib.runtime.CommandEnvironment;
import com.google.devtools.build.lib.runtime.KeepGoingOption;
import com.google.devtools.build.lib.runtime.LoadingPhaseThreadsOption;
import com.google.devtools.build.lib.skyframe.PackageLookupValue;
import com.google.devtools.build.lib.skyframe.PrecomputedValue;
import com.google.devtools.build.lib.skyframe.SkyframeExecutor;
Expand All @@ -50,7 +51,7 @@
/** Syncs all repositories specifed in the workspace file */
@Command(
name = SyncCommand.NAME,
options = {PackageCacheOptions.class, KeepGoingOption.class},
options = {PackageCacheOptions.class, KeepGoingOption.class, LoadingPhaseThreadsOption.class},
help = "resource:sync.txt",
shortDescription = "Syncs all repositories specifed in the workspace file",
allowResidue = false)
Expand Down Expand Up @@ -94,9 +95,10 @@ public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult opti

// Obtain the key for the top-level WORKSPACE file
SkyKey packageLookupKey = PackageLookupValue.key(Label.EXTERNAL_PACKAGE_IDENTIFIER);
LoadingPhaseThreadsOption threadsOption = options.getOptions(LoadingPhaseThreadsOption.class);
EvaluationContext evaluationContext =
EvaluationContext.newBuilder()
.setNumThreads(SkyframeExecutor.DEFAULT_THREAD_COUNT)
.setNumThreads(threadsOption.threads)
.setEventHander(env.getReporter())
.build();
EvaluationResult<SkyValue> packageLookupValue =
Expand Down

0 comments on commit 828b1fb

Please sign in to comment.