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

vmlatency: Fix latency comparison #243

Merged
merged 3 commits into from Feb 2, 2023

Conversation

orelmisan
Copy link
Member

Currently, if the actual measured latency is less than 1ms, it is considered as 0ms.
This created a small bug[1] when the max desired latency was 0ms.

Improve the comparison of the max desired latency and the actual measured latency.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=2156392

@orelmisan orelmisan changed the title Fix latency comparison vmlatency: Fix latency comparison Jan 26, 2023
Currently, the config.Config struct, holds a field named:
`DesiredMaxLatencyMilliseconds`.

Change this field type to `time.Duration` and remove
the `Milliseconds` suffix, in order to better compare it
with the actual measured latency during `Checkup.Run()`.

Signed-off-by: Orel Misan <omisan@redhat.com>
Change the error message format to use the string format
of `time.Duration` in order to improve readability.

Signed-off-by: Orel Misan <omisan@redhat.com>
Currently, `millisecondsPrefix` is used only as a suffix.
Change its name accordingly.

Signed-off-by: Orel Misan <omisan@redhat.com>
@orelmisan
Copy link
Member Author

Change: Added "vmlatency" prefix to commit message subject.

return Config{}, fmt.Errorf("%q parameter is invalid: %v", DesiredMaxLatencyMillisecondsParamName, err)
}

newConfig.DesiredMaxLatency = time.Duration(rawDesiredMaxLatencyMilliseconds) * time.Millisecond
Copy link
Member

Choose a reason for hiding this comment

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

How about using the built-in ParseDuration?

cost MillisecondUnit= "ms"
desiredMaxLatency, err := time.ParseDuration(rawDesiredMaxLatencyMilliseconds + MillisecondUnit)

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a great idea (that maybe could be implemented in the other checkups as well).
The problem is that it requires more changes to the unit test.
I prefer to do it in a follow-up PR.

Copy link
Collaborator

@RamLavi RamLavi Feb 2, 2023

Choose a reason for hiding this comment

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

either are ok by my book

Copy link
Collaborator

@RamLavi RamLavi left a comment

Choose a reason for hiding this comment

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

/lgtm

@orelmisan orelmisan merged commit 9e914ac into kiagnose:main Feb 2, 2023
@orelmisan orelmisan deleted the fixclatencycomparison branch February 2, 2023 06:44
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.

None yet

3 participants