diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 91521e9c6e..ec33d9ad02 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -30,6 +30,10 @@ v33.0.0 (next next, roadmap) license detection and reduce false positives. See https://github.com/nexB/scancode-toolkit/issues/3300 +- default value for `--processes` was previously 1. It was changed + to (number of CPUs)-1. + See https://github.com/aboutcode-org/scancode-toolkit/issues/2980 + - File categorization support added, a post scan plugin tagging files with priority levels for review, and also take advantage of these in other summary plugins. diff --git a/docs/source/cli-reference/help-text-options.rst b/docs/source/cli-reference/help-text-options.rst index 5e7a769460..58f0fe2e88 100644 --- a/docs/source/cli-reference/help-text-options.rst +++ b/docs/source/cli-reference/help-text-options.rst @@ -165,7 +165,7 @@ The Following Help Text is displayed, i.e. This is the help text for Scancode Ve seconds. [default: 120 seconds] -n, --processes INT Set the number of parallel processes to use. Disable parallel processing if 0. Also disable threading if - -1. [default: 1] + -1. [default: (number of CPUs)-1] -q, --quiet Do not print summary or progress. -v, --verbose Print progress as file-by-file path instead of a progress bar. Print verbose scan counters. diff --git a/docs/source/rst_snippets/core_options.rst b/docs/source/rst_snippets/core_options.rst index 277e9570d1..453763ca57 100644 --- a/docs/source/rst_snippets/core_options.rst +++ b/docs/source/rst_snippets/core_options.rst @@ -2,7 +2,7 @@ All "Core" Scan Options ----------------------- -n, --processes INTEGER Scan ```` using n parallel processes. - [Default: 1] + [Default: (number of CPUs)-1] -v, --verbose Print verbose file-by-file progress messages. diff --git a/src/scancode/cli.py b/src/scancode/cli.py index add654f2ec..9369fe7d91 100644 --- a/src/scancode/cli.py +++ b/src/scancode/cli.py @@ -201,6 +201,13 @@ def validate_input_path(ctx, param, value): return value +def default_processes(): + """ return number that is used as a default value for --processes """ + cpu_count = os.cpu_count() + if cpu_count > 1: + return cpu_count-1 + else: + return 1 @click.command(name='scancode', epilog=epilog_text, @@ -230,10 +237,10 @@ def validate_input_path(ctx, param, value): @click.option('-n', '--processes', type=int, - default=1, + default=default_processes(), metavar='INT', help='Set the number of parallel processes to use. ' - 'Disable parallel processing if 0. Also disable threading if -1. [default: 1]', + 'Disable parallel processing if 0. Also disable threading if -1. [default: (number of CPUs)-1]', help_group=cliutils.CORE_GROUP, sort_order=10, cls=PluggableCommandLineOption) @click.option('--timeout', diff --git a/tests/scancode/data/help/help.txt b/tests/scancode/data/help/help.txt index 6def63b889..8a486871b5 100644 --- a/tests/scancode/data/help/help.txt +++ b/tests/scancode/data/help/help.txt @@ -138,7 +138,7 @@ Options: seconds. [default: 120 seconds] -n, --processes INT Set the number of parallel processes to use. Disable parallel processing if 0. Also disable threading if - -1. [default: 1] + -1. [default: (number of CPUs)-1] -q, --quiet Do not print summary or progress. -v, --verbose Print progress as file-by-file path instead of a progress bar. Print verbose scan counters. diff --git a/tests/scancode/data/help/help_linux.txt b/tests/scancode/data/help/help_linux.txt index a6527a51f3..9ca1d26d68 100644 --- a/tests/scancode/data/help/help_linux.txt +++ b/tests/scancode/data/help/help_linux.txt @@ -140,7 +140,7 @@ Options: seconds. [default: 120 seconds] -n, --processes INT Set the number of parallel processes to use. Disable parallel processing if 0. Also disable threading if - -1. [default: 1] + -1. [default: (number of CPUs)-1] -q, --quiet Do not print summary or progress. -v, --verbose Print progress as file-by-file path instead of a progress bar. Print verbose scan counters.