Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The number of logical CPUs can be now set using --cpus flag #31

Merged
merged 3 commits into from
Nov 25, 2021

Conversation

lukher-dev
Copy link
Contributor

@lukher-dev lukher-dev commented Nov 20, 2021

This pull request adds the feature mentioned in issue #20

Copy link
Owner

@kffl kffl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking the time to implement this feature!

I only have some minor comments on code formatting, flag description and config default value. Also, would you mind adding an appropriate change to README.md? For now, adding --cpus flag to help output will be sufficient, as the there is a documentation overhaul planned in #26 anyway.

@@ -112,6 +114,7 @@ func TestGocannonDefaultValues(t *testing.T) {
cfg := common.Config{
Duration: &duration,
Connections: &connections,
CPUs: &cpus,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a minor formatting issue here - tabs between : and & instead of spaces

@@ -161,6 +165,7 @@ func TestGocanonWithPlugin(t *testing.T) {
cfg := common.Config{
Duration: &duration,
Connections: &connections,
CPUs: &cpus,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - tabs instead of spaces

args.go Outdated
@@ -44,6 +46,9 @@ func parseArgs() (common.Config, error) {
PlaceHolder("file.csv").
Short('o').
String(),
CPUs: app.Flag("cpus", "Maximum number of logical CPUs").
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Descriptions of all other flags end with a full stop. One extra sentence could be added: Defaults to the number of available CPU threads (or the GOMAXPROCS env variable).

args.go Outdated
@@ -44,6 +46,9 @@ func parseArgs() (common.Config, error) {
PlaceHolder("file.csv").
Short('o').
String(),
CPUs: app.Flag("cpus", "Maximum number of logical CPUs").
Default(strconv.Itoa(runtime.NumCPU())).
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit ify about setting the default value to runtime.NumCPU as it is possible that someone running Gocannon might set the desired value via GOMAXPROCS env variable. Consequently, such setting would be overwritten. Instead, I would suggest not setting the Default value at all, so that it is initialized with 0, which will not alter the existing value when passed to runtime.GOMAXPROCS(). Ditching the default flag value would require modifying printHeader() so that it retrieves the value from GOMAXPROCS() if the config value equals 0.

@kffl kffl linked an issue Nov 25, 2021 that may be closed by this pull request
@kffl kffl merged commit f96ac6a into kffl:master Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A flag to specify logical CPUs count
2 participants