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

Add CPU benchmark task #2066

Merged
merged 4 commits into from
Oct 16, 2023
Merged

Add CPU benchmark task #2066

merged 4 commits into from
Oct 16, 2023

Conversation

AbdelrahmanElawady
Copy link
Contributor

Description

Add benchmark task to run 4 times a day and reports the workload numbers during the benchmark.

Issues

)

// CPUBenchmarkTask defines CPU benchmark task data.
type CPUBenchmarkTask struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add more explanation on the fields, e.g taskID is that a sequential string?a uuid?or else?
schedule: i'm assuming that's a cron string? let's clear the ambiguity please

}

// CPUBenchmarkResult holds CPU benchmark results with the workloads number during the benchmark.
type CPUBenchmarkResult struct {
Copy link
Collaborator

@xmonader xmonader Oct 3, 2023

Choose a reason for hiding this comment

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

Is the Single/Multi process or a thread? can we add a few more info and even change the name to a include the full name (or that's because of the json marshalling?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can change the name of the fields but the data returned from zos.perf.get_all will still be single, multi and threads, is that fine?

func NewCPUBenchmarkTask() CPUBenchmarkTask {
return CPUBenchmarkTask{
taskID: "CPUBenchmark",
schedule: "0 0 */6 * * *",
Copy link
Collaborator

@xmonader xmonader Oct 3, 2023

Choose a reason for hiding this comment

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

can we move that cron string to a const and be used here?

if err != nil {
return nil, fmt.Errorf("failed to execute cpubench command: %w", err)
}
cpubenchData := struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need another anonymous struct while we have CPUBenchmarkResult?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as the JSON output does not have the workloads field and I don't know what the behavior of json package with missing fields.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm I think you can just do json:"-" for the field

https://go.dev/play/p/K6b-FOSs6e3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't use that because it will be ignored when querying the task data. I can just remove the anonymous struct and json ,I believe, will set it to the default value: 0

@@ -9,27 +9,32 @@ import (
"github.com/threefoldtech/zos/pkg/stubs"
)

const cpuBenchmarkTaskID = "CPUBenchmark"
const cpuBenchmarkCronScheule = "0 0 */6 * * *"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Schedule*

return context.WithValue(ctx, zbusClient{}, client)
}

func getZbusClient(ctx context.Context) zbus.Client {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func getZbusClient(ctx context.Context) zbus.Client {
func GetZbusClient(ctx context.Context) zbus.Client {

this should be public because external tasks can still use it

@muhamadazmy muhamadazmy merged commit 1d41a6f into main Oct 16, 2023
2 checks passed
@muhamadazmy muhamadazmy deleted the perf-task branch October 16, 2023 12:39
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.

3 participants