tern-tools / tern

Tern is a software composition analysis tool and Python library that generates a Software Bill of Materials for container images and Dockerfiles. The SBOM that Tern generates will give you a layer-by-layer view of what's inside your container in a variety of formats including human-readable, JSON, HTML, SPDX and more.
BSD 2-Clause "Simplified" License
967 stars 188 forks source link

ScanCode should run with n-1 cores, instead of using all available resources #1062

Closed maxhbr closed 3 years ago

maxhbr commented 3 years ago

AFAIK it is recommended to run ScanCode with with one less core than is available. So it would be probably better to replace

https://github.com/tern-tools/tern/blob/87e7cdd154bc3cad98db1174b192ab9592adcffb/tern/extensions/scancode/executor.py#L139

by

command = "scancode -ilpcu --quiet --timeout 300 -n {} --json -".format(processes - 1) 
maxhbr commented 3 years ago

@pombredanne: am I wrong about that?

pombredanne commented 3 years ago

@maxhbr ScanCode is happy to use it all, but it typically helps to use one less core to avoid saturating the CPU: this way it leaves some CPU cycles for the user. For instance on my laptop which is a quad core with 8 threads, I typically run with -n7.

sayantani11 commented 3 years ago

@rnjudge Can I take this? But I need a bit more explanation. @maxhbr

rnjudge commented 3 years ago

@sayantani11 go for it! The required change is just as suggested in Max's comment. It is a one liner.