Skip to content

Commit

Permalink
Default to single threaded gathering of procs
Browse files Browse the repository at this point in the history
Due to load spikes on servers with many processes it's better to gather procs in a single thread.
  • Loading branch information
fuegas committed Jun 3, 2020
1 parent 02a6ba0 commit baf31ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions cmd/psstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The options are:
--cache-dir <name> Name of the directory to store the stats cache (default: /mnt/psstat)
--cache-name <name> Name of the file to store the stats cache (in cache-dir)
--single-threaded Run process gathering in a single thread, this can avoid strange load spikes on servers with many processes.
--multi-threaded Run process gathering in multiple threads, this can cause strange load spikes on servers with many processes.
--help Show this description
--version Show the current version
Expand Down Expand Up @@ -79,8 +79,8 @@ var fCacheDir = flag.String("cache-dir", "/tmp",
var fCacheName = flag.String("cache-name", "psstat",
"store cache data in a file with this name")

var fSingleThreaded = flag.Bool("single-threaded", false,
"Run process gathering on a single thread")
var fMultiThreaded = flag.Bool("multi-threaded", false,
"Run process gathering on a multiple threads")

var fVersion = flag.Bool("version", false, "Show the current version")

Expand Down Expand Up @@ -183,7 +183,7 @@ func main() {
// Aggregate all known processes
currentTime := time.Now().UnixNano()
var procs map[PID]*Process
procs, err = GatherAllProcs(*fSingleThreaded)
procs, err = GatherAllProcs(*fMultiThreaded)
if err != nil {
exitError("Failed to gather process information:", err)
}
Expand Down
8 changes: 4 additions & 4 deletions process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ type Process struct {
//
// When it builds the map, the relevant information of a Process is read from
// stat and statm
func GatherAllProcs(singleThreaded bool) (map[PID]*Process, error) {
if singleThreaded {
return GatherAllProcsSingleThreaded()
} else {
func GatherAllProcs(multiThreaded bool) (map[PID]*Process, error) {
if multiThreaded {
return GatherAllProcsMultiThreaded()
} else {
return GatherAllProcsSingleThreaded()
}
}

Expand Down

0 comments on commit baf31ae

Please sign in to comment.