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

Rebase facebook/buck 10/2020 #9

Merged
merged 38 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1c31c5b
Respect user input if abi_generation_mode is explicitly provided in j…
davidhao3300 Jun 25, 2020
da5384f
Automate publishing docs on CirclrCI (#2486)
Jun 29, 2020
3283f1c
Fixed git push access denied issue (#2487)
Jun 29, 2020
0aeb8be
handle bundling resources of static frameworks (Originally by rmaz) (…
Unknoob Jul 10, 2020
0299f0f
Add support for java 11 builds in jitpack (#2499)
kageiit Jul 20, 2020
888cae1
Fixed Unable to resolve dependency jdk8 (= 8.0.172) (#2492)
Jul 22, 2020
c29414a
CircleCI fix (#2495)
Jul 22, 2020
992456c
Added python3 to interpreter names (#2497)
Jul 22, 2020
c381e7c
Fixes for rust tests (#2503)
Jul 30, 2020
c30a8be
Add support for ANDROID_SDK_ROOT environment variable (#2507)
Jul 30, 2020
290308e
Fix for #2498 (#2504)
surapuramakhil Jul 30, 2020
c12ddfe
Set max store size bytes correctly so it is used by AbstractAsynchron…
raviagarwal7 Aug 3, 2020
7486182
CI rust test fixes (#2511)
Aug 5, 2020
d62d9b2
Fixed a phthon installation bug on CircleCI (#2509)
Aug 5, 2020
cac7c76
add Easynvest to buck showcases (#2514)
Lcsmarcal Aug 6, 2020
427f770
Make Python3 the first choice of python interpreter (#2512)
Aug 6, 2020
39a6610
Fixed a python3 compatible issue (#2517)
Aug 12, 2020
ff103fc
Added application_region and application_language properties to xcode…
Lcsmarcal Aug 12, 2020
d1717fd
Added Android NDK tests (#2515)
Aug 13, 2020
a68ef0d
Saifulriza (#2523)
saifulriza Aug 17, 2020
1c601fd
Add full kotlin configurations to kotlin rule (v2) (#2526)
tyvsmith Aug 25, 2020
d9d41a5
Fixing paths that fail during project generation (#2527)
tyvsmith Aug 25, 2020
ffa062a
(Rebase) Add snapshot_images_diff_path to apple_test (#2528)
Lcsmarcal Aug 25, 2020
7273a9d
Fixes for Windows tests (#2529)
Aug 28, 2020
6ce4daa
Added Flavors to docs (#2522)
Aug 28, 2020
2c78fcb
Added a kotlin tutorial for android (#2525)
Aug 31, 2020
6a45969
Prepare release v2020.09.01 (#2532)
Sep 1, 2020
b12b77f
Added dependency to pulbishing docs (#2534)
Sep 2, 2020
ff7c4cd
Fixed CircleCI tests (#2531)
Sep 2, 2020
cd9fbc8
Upgraded ruby syntax in replease process (#2533)
Sep 2, 2020
ffd2df6
Skip flaky tests on Windows platform (#2536)
Sep 9, 2020
682b0aa
Increased a timeout in Winddows test. (#2544)
Sep 22, 2020
2ab66a9
Fixed dlang installation error (#2543)
Sep 22, 2020
e5f9062
Install python2 from archive. (#2542)
Sep 22, 2020
a103d9b
Fixed a link (#2539)
Sep 22, 2020
ae8e8fc
Added a rust tutorial (#2540)
Oct 6, 2020
32440f9
Add support for async worker processes (#2547)
mikekap Oct 13, 2020
7b8881b
Merge branch 'facebook_master' into rebase-10-2020
Oct 20, 2020
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
Prev Previous commit
Next Next commit
Add support for async worker processes (facebook#2547)
* Allow WorkerProcess to be used for multiple jobs at the same time.

No users yet, but next up is the process pool.

* Introduce a new `async` option to worker tools.

This makes buck call the tool concurrently, without waiting for responses. It's up to the tool to provide responses with the right ids, in any order.

* Write some tests, fix some bugs

* Add back license

* Update WorkerProcessPool.java

* Fix windows tests

Don't crash all of buck when a worker process fails.

* Code review feedback and clarifications, I hope
  • Loading branch information
mikekap authored Oct 13, 2020
commit 32440f9bb50e802a7671eef5f32a19a76972c319
1 change: 1 addition & 0 deletions src/com/facebook/buck/features/js/JsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ static WorkerShellStep jsonWorkerShellStepAddingFlavors(
tool.getCommandPrefix(pathResolver),
tool.getEnvironment(pathResolver),
worker.getMaxWorkers(),
worker.isAsync(),
worker.isPersistent()
? Optional.of(
WorkerProcessIdentity.of(buildTarget.toString(), worker.getInstanceKey()))
Expand Down
4 changes: 4 additions & 0 deletions src/com/facebook/buck/rules/macros/WorkerMacroArg.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ public int getMaxWorkers() {
return workerTool.getMaxWorkers();
}

public boolean isAsync() {
return workerTool.isAsync();
}

public String getJobArgs(SourcePathResolverAdapter pathResolver) {
return Arg.stringify(arg, pathResolver).trim();
}
Expand Down
22 changes: 21 additions & 1 deletion src/com/facebook/buck/shell/DefaultWorkerToolRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ protected DefaultWorkerToolRule(
SourcePathRuleFinder ruleFinder,
Tool tool,
int maxWorkers,
boolean isAsync,
boolean isPersistent) {
super(
buildTarget,
Expand All @@ -71,6 +72,7 @@ protected DefaultWorkerToolRule(
new DefaultWorkerTool(
new DefaultWorkerToolDelegatingTool(tool, getSourcePathToOutput()),
maxWorkers,
isAsync,
isPersistent,
buildTarget,
generateNewUUID());
Expand Down Expand Up @@ -141,6 +143,13 @@ static class DefaultWorkerTool implements WorkerTool {
@CustomFieldBehavior(DefaultFieldSerialization.class)
private final Integer maxWorkers;

/**
* Important : Do not add this field into RuleKey. Rule key should not change in case of async
* variable modification.
*/
@CustomFieldBehavior(DefaultFieldSerialization.class)
private final boolean isAsync;

/**
* Important : Do not add this field into RuleKey. Rule key should not change in case of
* instance key modification (that is calculated during creation as random UUID).
Expand All @@ -149,11 +158,17 @@ static class DefaultWorkerTool implements WorkerTool {
private HashCode instanceKey;

DefaultWorkerTool(
Tool tool, int maxWorkers, boolean isPersistent, BuildTarget buildTarget, UUID uuid) {
Tool tool,
int maxWorkers,
boolean isAsync,
boolean isPersistent,
BuildTarget buildTarget,
UUID uuid) {
this.tool = tool;
this.maxWorkers = maxWorkers;
this.isPersistent = isPersistent;
this.buildTarget = buildTarget;
this.isAsync = isAsync;
this.instanceKey = calculateInstanceKey(uuid);
}

Expand All @@ -180,6 +195,11 @@ public int getMaxWorkers() {
return maxWorkers;
}

@Override
public boolean isAsync() {
return isAsync;
}

@Override
public boolean isPersistent() {
return isPersistent;
Expand Down
4 changes: 3 additions & 1 deletion src/com/facebook/buck/shell/GenruleBuildable.java
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,8 @@ public void addEnvironmentVariables(
androidTools.ifPresent(
tools -> {
environmentVariablesBuilder.put("ANDROID_HOME", tools.getAndroidSdkLocation().toString());
environmentVariablesBuilder.put("ANDROID_SDK_ROOT", tools.getAndroidSdkLocation().toString());
environmentVariablesBuilder.put(
"ANDROID_SDK_ROOT", tools.getAndroidSdkLocation().toString());
environmentVariablesBuilder.put("DX", tools.getAndroidPathToDx().toString());
environmentVariablesBuilder.put("ZIPALIGN", tools.getAndroidPathToZipalign().toString());
environmentVariablesBuilder.put(
Expand Down Expand Up @@ -760,6 +761,7 @@ private static Optional<WorkerJobParams> convertToWorkerJobParams(
workerMacroArg.getStartupCommand(),
workerMacroArg.getEnvironment(),
workerMacroArg.getMaxWorkers(),
workerMacroArg.isAsync(),
workerMacroArg.getPersistentWorkerKey().isPresent()
? Optional.of(
WorkerProcessIdentity.of(
Expand Down
14 changes: 10 additions & 4 deletions src/com/facebook/buck/shell/WorkerShellStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@
import com.facebook.buck.worker.WorkerJobParams;
import com.facebook.buck.worker.WorkerJobResult;
import com.facebook.buck.worker.WorkerProcessPool;
import com.facebook.buck.worker.WorkerProcessPool.BorrowedWorkerProcess;
import com.facebook.buck.worker.WorkerProcessPoolFactory;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap;
import java.io.IOException;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;

public class WorkerShellStep implements Step {
Expand Down Expand Up @@ -78,9 +79,14 @@ public StepExecutionResult execute(ExecutionContext context)
WorkerJobParams paramsToUse = getWorkerJobParamsToUse(context.getPlatform());
WorkerProcessPool pool =
factory.getWorkerProcessPool(context, paramsToUse.getWorkerProcessParams());
WorkerJobResult result;
try (BorrowedWorkerProcess process = pool.borrowWorkerProcess()) {
result = process.submitAndWaitForJob(getExpandedJobArgs(context));
WorkerJobResult result = null;
try {
result = pool.submitJob(getExpandedJobArgs(context)).get();
} catch (ExecutionException e) {
if (e.getCause() != null) {
Throwables.throwIfUnchecked(e.getCause());
}
throw new RuntimeException(e);
}

Verbosity verbosity = context.getVerbosity();
Expand Down
2 changes: 2 additions & 0 deletions src/com/facebook/buck/shell/WorkerTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ public interface WorkerTool extends AddsToRuleKey {
boolean isPersistent();

HashCode getInstanceKey();

boolean isAsync();
}
5 changes: 5 additions & 0 deletions src/com/facebook/buck/shell/WorkerToolDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ public BuildRule createBuildRule(
builder.addEnv(e.getKey(), macrosConverter.convert(e.getValue()));
}

boolean async = args.getSoloAsync().orElse(false);

Preconditions.checkArgument(
!(args.getMaxWorkers().isPresent() && args.getMaxWorkersPerThreadPercent().isPresent()),
"max_workers and max_workers_per_thread_percent must not be used together.");
Expand Down Expand Up @@ -154,6 +156,7 @@ public BuildRule createBuildRule(
graphBuilder,
tool,
maxWorkers,
async,
args.getPersistent()
.orElse(buckConfig.getBooleanValue(CONFIG_SECTION, CONFIG_PERSISTENT_KEY, false)));
}
Expand Down Expand Up @@ -197,5 +200,7 @@ default Either<StringWithMacros, ImmutableList<StringWithMacros>> getArgs() {
Optional<Integer> getMaxWorkersPerThreadPercent();

Optional<Boolean> getPersistent();

Optional<Boolean> getSoloAsync();
}
}
2 changes: 2 additions & 0 deletions src/com/facebook/buck/worker/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ java_immutables_library(
"WorkerProcess.java",
"WorkerProcessCommand.java",
"WorkerProcessPool.java",
"WorkerProcessPoolAsync.java",
"WorkerProcessPoolSync.java",
"WorkerProcessProtocol.java",
"WorkerProcessProtocolZero.java",
],
Expand Down
Loading