Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #99 from kochd/master
Browse files Browse the repository at this point in the history
add -no-limit parameter
  • Loading branch information
phendryx authored Dec 1, 2021
2 parents a86bc07 + aaf0d1f commit 6cb6c2f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
7 changes: 7 additions & 0 deletions albiondata-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ func init() {
false,
"Ignore the decoding errors when debugging",
)

flag.BoolVar(
&client.ConfigGlobal.NoCPULimit,
"no-limit",
false,
"Use all available CPU cores",
)
}

func main() {
Expand Down
1 change: 1 addition & 0 deletions client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type config struct {
RecordPath string
PrivateIngestBaseUrls string
PublicIngestBaseUrls string
NoCPULimit bool
}

//ConfigGlobal global config data
Expand Down
12 changes: 7 additions & 5 deletions client/uploader_http_pow.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ type Pow struct {
// newHTTPUploaderPow creates a new HTTP uploader
func newHTTPUploaderPow(url string) uploader {

// Limit to 25% of available cpu cores
procs := runtime.NumCPU() / 4
if procs < 1 {
procs = 1
if !ConfigGlobal.NoCPULimit {
// Limit to 25% of available cpu cores
procs := runtime.NumCPU() / 4
if procs < 1 {
procs = 1
}
runtime.GOMAXPROCS(procs)
}
runtime.GOMAXPROCS(procs)

return &httpUploaderPow{
baseURL: strings.Replace(url, "http+pow", "http", -1),
Expand Down

0 comments on commit 6cb6c2f

Please sign in to comment.