-
Notifications
You must be signed in to change notification settings - Fork 33
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
Conntrack latency measurement recipe #376
Closed
Closed
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a991476
LongLivedConnectionsMixin: methods split
enhaut 9749801
Results: added samples_slice method
enhaut b6f3501
Results/PerfList: added merge method
enhaut f292d85
Results: added Scalar samples/results support
enhaut 6aeb79b
LatencyMeasurement: added support for measuring latency
enhaut 94cb414
CTLatencyOnCacheMissRecipe: added recipe for measuring conntrack latency
enhaut File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,43 @@ def end_timestamp(self): | |
def time_slice(self, start, end): | ||
raise NotImplementedError() | ||
|
||
class ScalarSample(PerfResult): | ||
def __init__(self, value, unit, timestamp): | ||
self._value = value | ||
self._unit = unit | ||
self._timestamp = timestamp | ||
|
||
@property | ||
def value(self): | ||
return self._value | ||
|
||
@property | ||
def duration(self): | ||
return 1 # just to make it compatible with other PerfInterval objects | ||
|
||
@property | ||
def unit(self): | ||
return self._unit | ||
|
||
@property | ||
def start_timestamp(self): | ||
return self._timestamp | ||
|
||
@property | ||
def end_timestamp(self): | ||
return self._timestamp | ||
|
||
def time_slice(self, start, end): | ||
if end <= self.start_timestamp or start >= self.end_timestamp: | ||
raise EmptySlice( | ||
"current start, end {} {}; request start, end {}, {}".format( | ||
self.start_timestamp, self.end_timestamp, start, end, | ||
) | ||
) | ||
|
||
return ScalarSample(self.value, self.unit, self.start_timestamp) | ||
|
||
|
||
class PerfInterval(PerfResult): | ||
def __init__(self, value, duration, unit, timestamp): | ||
self._value = value | ||
|
@@ -110,7 +147,8 @@ def _validate_item(self, item): | |
|
||
def _validate_item_type(self, item): | ||
if (not isinstance(item, PerfInterval) and | ||
not isinstance(item, PerfList)): | ||
not isinstance(item, PerfList) and | ||
not isinstance(item, ScalarSample)): | ||
raise LnstError("{} only accepts PerfInterval or PerfList objects." | ||
.format(self.__class__.__name__)) | ||
|
||
|
@@ -165,7 +203,7 @@ def merge_with(self, iterable): | |
if type(val1) != type(val2): | ||
raise LnstError("Cannot merge different types of PerfList objects.") | ||
|
||
if isinstance(val1[0], PerfInterval): | ||
if isinstance(val1[0], PerfInterval) or isinstance(val1[0], ScalarSample): | ||
container = val1.__class__() | ||
container.extend(val1) | ||
container.extend(val2) | ||
|
@@ -201,7 +239,7 @@ def samples_slice(self, slicer: callable): | |
if len(self) == 0: | ||
raise EmptySlice("No samples to slice.") | ||
|
||
if isinstance(self[0], PerfInterval): | ||
if isinstance(self[0], PerfInterval) or isinstance(self[0], ScalarSample): | ||
result.extend(self[slicer]) | ||
elif isinstance(self[0], PerfList): | ||
for item in self: | ||
|
@@ -234,6 +272,11 @@ def start_timestamp(self): | |
def end_timestamp(self): | ||
return self[-1].end_timestamp | ||
|
||
|
||
class SequentialScalarResult(SequentialPerfResult): | ||
pass | ||
|
||
|
||
class ParallelPerfResult(PerfList, PerfResult): | ||
@property | ||
def value(self): | ||
|
@@ -260,6 +303,15 @@ def start_timestamp(self): | |
def end_timestamp(self): | ||
return max([i.end_timestamp for i in self]) | ||
|
||
|
||
class ParallelScalarResult(ParallelPerfResult): | ||
@property | ||
def average(self): | ||
samples_count = sum([len(i) for i in self]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this won't work if:
as ScalarSample doesn't support |
||
|
||
return self.value / samples_count | ||
|
||
|
||
def result_averages_difference(a, b): | ||
if a is None or b is None: | ||
return None | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about this implementation considering it's still using duration and has time slicing.... at least this should be refactored so that the common
PerfInterval
andScalarSample
property getters are in some common class...