Skip to content

Commit

Permalink
change default value of --process to (number of CPUs)-1
Browse files Browse the repository at this point in the history
Related: #2980
Signed-off-by: Miroslav Suchý <[email protected]>
  • Loading branch information
xsuchy committed Jan 18, 2025
1 parent b0aff52 commit 3726840
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/cli-reference/help-text-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/rst_snippets/core_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ All "Core" Scan Options
-----------------------

-n, --processes INTEGER Scan ``<input>`` using n parallel processes.
[Default: 1]
[Default: (number of CPUs)-1]

-v, --verbose Print verbose file-by-file progress messages.

Expand Down
11 changes: 9 additions & 2 deletions src/scancode/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 3726840

Please sign in to comment.