From b4d1c838c5ba2a8befbb929c55a70c738ed6e7c0 Mon Sep 17 00:00:00 2001 From: Ben Boyter Date: Mon, 30 Sep 2024 16:08:03 +1000 Subject: [PATCH] More options to control goroutines --- SCC-OUTPUT-REPORT.html | 90 ++++++++++++++++-------------------------- main.go | 25 ++++++++++++ processor/processor.go | 4 ++ 3 files changed, 64 insertions(+), 55 deletions(-) diff --git a/SCC-OUTPUT-REPORT.html b/SCC-OUTPUT-REPORT.html index 333e18d57..ab781d0fe 100644 --- a/SCC-OUTPUT-REPORT.html +++ b/SCC-OUTPUT-REPORT.html @@ -12,14 +12,14 @@ Go - 30 - 9637 - 1482 - 469 - 7686 - 1536 - 256898 - 4098 + 28 + 9570 + 1462 + 452 + 7656 + 1528 + 255227 + 4068 processor/formatters.go @@ -63,23 +63,23 @@ processor/processor.go - 671 + 672 141 104 - 426 + 427 92 - 19411 - 438 + 19457 + 439 main.go - 404 + 429 10 6 - 388 + 413 10 - 8969 - 256 + 9693 + 271 processor/detector_test.go @@ -220,16 +220,6 @@ 19 2043 60 - - processor/processor_unix.go - - 69 - 14 - 14 - 41 - 8 - 2030 - 52 processor/filereader.go @@ -250,16 +240,6 @@ 0 2209 35 - - processor/bloom.go - - 37 - 7 - 12 - 18 - 2 - 1062 - 29 processor/cocomo_test.go @@ -270,6 +250,16 @@ 6 686 23 + + processor/bloom.go + + 37 + 7 + 12 + 18 + 2 + 1062 + 29 processor/helpers_test.go @@ -280,16 +270,6 @@ 4 434 18 - - processor/processor_unix_test.go - - 24 - 6 - 3 - 15 - 0 - 411 - 16 examples/language/go.go @@ -323,16 +303,16 @@ Total - 30 - 9637 - 1482 - 469 - 7686 - 1536 - 256898 - 4098 + 28 + 9570 + 1462 + 452 + 7656 + 1528 + 255227 + 4068 - Estimated Cost to Develop (organic) $229,922
Estimated Schedule Effort (organic) 7.87 months
Estimated People Required (organic) 2.60
+ Estimated Cost to Develop (organic) $228,979
Estimated Schedule Effort (organic) 7.85 months
Estimated People Required (organic) 2.59
\ No newline at end of file diff --git a/main.go b/main.go index b2898a9c4..2cf5ea34b 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ package main import ( "fmt" "os" + "runtime" "strings" "github.com/boyter/scc/v3/processor" @@ -140,6 +141,30 @@ func main() { 10000, "number of files to parse before turning the GC on", ) + flags.IntVar( + &processor.FileListQueueSize, + "file-list-queue-size", + runtime.NumCPU(), + "the size of the queue of files found and ready to be read into memory", + ) + flags.IntVar( + &processor.FileProcessJobWorkers, + "file-process-job-workers", + runtime.NumCPU(), + "number of goroutine workers that process files collecting stats", + ) + flags.IntVar( + &processor.FileSummaryJobQueueSize, + "file-summary-job-queue-size", + runtime.NumCPU(), + "the size of the queue used to hold processed file statistics before formatting", + ) + flags.IntVar( + &processor.DirectoryWalkerJobWorkers, + "directory-walker-job-workers", + 8, + "controls the maximum number of workers which will walk the directory tree", + ) flags.StringVarP( &processor.Format, "format", diff --git a/processor/processor.go b/processor/processor.go index b674212dd..47f48da3f 100644 --- a/processor/processor.go +++ b/processor/processor.go @@ -165,6 +165,9 @@ var FileProcessJobWorkers = runtime.NumCPU() * 4 // FileSummaryJobQueueSize is the queue used to hold processed file statistics before formatting var FileSummaryJobQueueSize = runtime.NumCPU() +// DirectoryWalkerJobWorkers is the number of workers which will walk the directory tree +var DirectoryWalkerJobWorkers = 8 + // AllowListExtensions is a list of extensions which are allowed to be processed var AllowListExtensions = []string{} @@ -609,6 +612,7 @@ func Process() { fileWalker.IgnoreGitModules = GitModuleIgnore fileWalker.IncludeHidden = true fileWalker.ExcludeDirectory = PathDenyList + fileWalker.SetConcurrency(DirectoryWalkerJobWorkers) for _, exclude := range Exclude { regexpResult, err := regexp.Compile(exclude)