Skip to content

Commit 7df2639

Browse files
committed
feat: use multiprocessing workers for enhanced performance
1 parent b511e75 commit 7df2639

File tree

6 files changed

+214
-163
lines changed

6 files changed

+214
-163
lines changed

.github/workflows/test-app.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: astral-sh/setup-uv@v6
2424

2525
- name: install dependencies
26-
run: uv sync --verbose
26+
run: uv sync --all-extras --verbose
2727

2828
- name: pylint
2929
run: uv run pylint --fail-on=E src/

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,18 +266,17 @@ constraints against themselves.
266266

267267
### Increase Rendering Speed with Concurrency
268268

269-
Hydrator has added support for asynchronous hydration of cluster and package manifests using event-based concurrency. It
270-
is disabled by default. To use, pass the `--workers` flag during invocation. For example:
269+
Hydrator is designed for high-performance, parallel execution of CPU-bound hydration tasks. It automatically uses a process-based concurrency model to take full advantage of multi-core systems, bypassing Python's Global Interpreter Lock (GIL).
270+
271+
By default, Hydrator will spawn a number of worker processes equal to the number of CPU cores on the system. You can override this behavior by passing the `--workers` flag:
271272

272273
```shell
273274
hydrate -v --workers=32 cluster sot.csv --gatekeeper-validation --split-output
274275
```
275276

276-
The recommended number of workers to use is 2 for every CPU core available. If you are still not seeing the performance
277-
improvements you would like, we recommend allocating more CPUs to hydrator and to increase the number of workers
278-
accordingly. For example, if you have allocated 16 (v)CPUS, use 32 workers.
277+
The optimal number of workers can vary depending on the workload and system resources. A good starting point is one worker per available CPU core, but experimentation is encouraged. More available CPUs will always result in better performance.
279278

280-
> **Note:** Increasing the number of concurrent workers can dramatically reduce the usefulness of hydrator output, as the logs from concurrent tasks will be interleaved in the console. If you are troubleshooting a local developer workflow, it is suggested to disable hydration concurrency by omitting the `--workers` flag to ensure clear, sequential output.
279+
> **Note:** When multiple workers are active, their log outputs will be interleaved in the console. For troubleshooting a specific hydration, it is recommended to limit the run to a single worker (`--workers=1`) to ensure clear, sequential output.
281280
282281
### Filtering
283282

@@ -377,7 +376,7 @@ Note that functionality is split across subcommands:
377376

378377
```
379378
$ hydrate --help
380-
usage: hydrate [-h] [-v | -q] [--workers WORKERS] {cluster,package} ...
379+
usage: hydrate [-h] [-v | -q] [--workers WORKERS] [--version] {cluster,package} ...
381380
382381
positional arguments:
383382
{cluster,package}
@@ -388,7 +387,8 @@ options:
388387
-h, --help show this help message and exit
389388
-v, --verbose increase output verbosity; -vv for max verbosity
390389
-q, --quiet output errors only
391-
--workers WORKERS
390+
--workers WORKERS Overrides the number of worker processes to use for hydration. By default the number of worker processes is the number of processors on the machine.
391+
--version show program's version number and exit
392392
```
393393

394394
## Development
@@ -432,7 +432,7 @@ of this writing, asyncronous hydration using asyncio completes approximately 85%
432432

433433
There is an additional set of tests assets at `tests/assets/platform_valid_async_perf_testing` which contain ~1000
434434
clusters for evaluation and test of performance enhancements/improvements. Hydration of these resources completes in
435-
approximately ~149s.
435+
approximately ~44s.
436436

437437
### Building Docker Container
438438

src/hydrator/__main__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# limitations under the License.
1515
#
1616
###############################################################################
17-
import asyncio
1817
import pprint
1918
import sys
2019

@@ -101,7 +100,7 @@ def main() -> int:
101100
logger.error(e)
102101
return 1
103102

104-
return asyncio.run(cli.run())
103+
return cli.run()
105104

106105

107106
if __name__ == '__main__':

0 commit comments

Comments
 (0)