This repository has been archived by the owner on Dec 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Limit the maximum number of hh_client processes to run in parallel (#400
) * Rename ParseQueue to ProcessExecutionQueue, supporting processes other than `hh_parse` * Limit the number of `hh_client` processes
- Loading branch information
Showing
5 changed files
with
67 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2017-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
|
||
namespace Facebook\HHAST\__Private; | ||
|
||
use namespace HH\Lib\Async; | ||
|
||
final class ProcessExecutionQueue { | ||
|
||
<<__Memoize>> | ||
private function impl(): Async\Semaphore<vec<string>, vec<string>> { | ||
return new Async\Semaphore( | ||
$this->limit, | ||
async (vec<string> $args) ==> | ||
await execute_async($this->process_name, ...$args), | ||
); | ||
} | ||
|
||
public function __construct( | ||
private int $limit, | ||
private string $process_name, | ||
)[] { | ||
} | ||
|
||
public async function waitForAsync( | ||
vec<string> $args, | ||
): Awaitable<vec<string>> { | ||
return await $this->impl()->waitForAsync($args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (c) 2017-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
|
||
namespace Facebook\HHAST\__Private; | ||
|
||
enum class ProcessExecutionQueues: ProcessExecutionQueue { | ||
|
||
// Random number; it might seem high, but it's likely that `hh_parse` will | ||
// execute quick enough that most of the processes are waiting to be cleaned | ||
// up | ||
ProcessExecutionQueue HH_CLIENT = | ||
new ProcessExecutionQueue(32, 'hh_client'); | ||
ProcessExecutionQueue HH_PARSE = new ProcessExecutionQueue(32, 'hh_parse'); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters