-
Notifications
You must be signed in to change notification settings - Fork 338
Add per window throughput #2126
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
Open
gareth-ellis
wants to merge
5
commits into
master
Choose a base branch
from
per-window-throughput
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+60
−8
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
954ea4c
Add per window throughput
gareth-ellis bbd8730
Update method
gareth-ellis 8db1cae
Remove unused _prev_total_count from TaskStats
Copilot 6235fee
Fix throughput window config parsing as boolean
Copilot 89e9573
docs: document throughput window reporting setting
Copilot 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 hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -719,10 +719,13 @@ def prepare_benchmark(self, t): | |
| self.challenge = select_challenge(self.config, self.track) | ||
| self.quiet = self.config.opts("system", "quiet.mode", mandatory=False, default_value=False) | ||
| downsample_factor = int(self.config.opts("reporting", "metrics.request.downsample.factor", mandatory=False, default_value=1)) | ||
| windowed_throughput = convert.to_bool( | ||
| self.config.opts("reporting", "metrics.request.throughput.window", mandatory=False, default_value=False) | ||
| ) | ||
| self.metrics_store = metrics.metrics_store(cfg=self.config, track=self.track.name, challenge=self.challenge.name, read_only=False) | ||
|
|
||
| self.sample_post_processor = SamplePostprocessor( | ||
| self.metrics_store, downsample_factor, self.track.meta_data, self.challenge.meta_data | ||
| self.metrics_store, downsample_factor, self.track.meta_data, self.challenge.meta_data, windowed_throughput=windowed_throughput | ||
| ) | ||
|
gareth-ellis marked this conversation as resolved.
|
||
|
|
||
| es_clients = self.create_es_clients() | ||
|
|
@@ -1044,13 +1047,14 @@ def post_process_samples(self): | |
|
|
||
|
|
||
| class SamplePostprocessor: | ||
| def __init__(self, metrics_store, downsample_factor, track_meta_data, challenge_meta_data): | ||
| def __init__(self, metrics_store, downsample_factor, track_meta_data, challenge_meta_data, windowed_throughput=False): | ||
| self.logger = logging.getLogger(__name__) | ||
| self.metrics_store = metrics_store | ||
| self.track_meta_data = track_meta_data | ||
| self.challenge_meta_data = challenge_meta_data | ||
| self.throughput_calculator = ThroughputCalculator() | ||
| self.downsample_factor = downsample_factor | ||
| self.windowed_throughput = windowed_throughput | ||
|
|
||
| def __call__(self, raw_samples): | ||
| if len(raw_samples) == 0: | ||
|
|
@@ -1127,7 +1131,7 @@ def __call__(self, raw_samples): | |
| end = time.perf_counter() | ||
| self.logger.debug("Storing latency and service time took [%f] seconds.", (end - start)) | ||
| start = end | ||
| aggregates = self.throughput_calculator.calculate(raw_samples) | ||
| aggregates = self.throughput_calculator.calculate(raw_samples, windowed=self.windowed_throughput) | ||
| end = time.perf_counter() | ||
| self.logger.debug("Calculating throughput took [%f] seconds.", (end - start)) | ||
| start = end | ||
|
|
@@ -1645,11 +1649,18 @@ def __init__(self, bucket_interval, sample_type, start_time): | |
| self.has_samples_in_sample_type = False | ||
| # start relative to the beginning of our (calculation) time slice. | ||
| self.start_time = start_time | ||
| self._prev_interval = 0 | ||
| self._windowed_rate = None | ||
|
|
||
| @property | ||
| def throughput(self): | ||
| return self.total_count / self.interval | ||
|
|
||
| @property | ||
| def windowed_throughput(self): | ||
| """Throughput based only on ops and time elapsed since the previous bucket boundary.""" | ||
| return self._windowed_rate if self._windowed_rate is not None else self.throughput | ||
|
|
||
|
Comment on lines
+1659
to
+1663
Contributor
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. Can we avoid fallback to running average ( |
||
| def maybe_update_sample_type(self, current_sample_type): | ||
| if self.sample_type < current_sample_type: | ||
| self.sample_type = current_sample_type | ||
|
|
@@ -1665,6 +1676,10 @@ def can_add_final_throughput_sample(self): | |
| return self.interval > 0 and not self.has_samples_in_sample_type | ||
|
|
||
| def finish_bucket(self, new_total): | ||
| delta_count = new_total - self.total_count | ||
| delta_interval = self.interval - self._prev_interval | ||
| self._windowed_rate = delta_count / delta_interval if delta_interval > 0 else None | ||
| self._prev_interval = self.interval | ||
| self.unprocessed = [] | ||
| self.total_count = new_total | ||
| self.has_samples_in_sample_type = True | ||
|
|
@@ -1673,12 +1688,14 @@ def finish_bucket(self, new_total): | |
| def __init__(self): | ||
| self.task_stats = {} | ||
|
|
||
| def calculate(self, samples, bucket_interval_secs=1): | ||
| def calculate(self, samples, bucket_interval_secs=1, windowed=False): | ||
| """ | ||
| Calculates global throughput based on samples gathered from multiple load generators. | ||
|
|
||
| :param samples: A list containing all samples from all load generators. | ||
| :param bucket_interval_secs: The bucket interval for aggregations. | ||
| :param windowed: When True, each throughput sample reflects only the ops since the previous bucket | ||
| rather than the cumulative average since task start. | ||
| :return: A global view of throughput samples. | ||
| """ | ||
|
|
||
|
|
@@ -1708,14 +1725,14 @@ def calculate(self, samples, bucket_interval_secs=1): | |
| # only transform the values into the expected structure. | ||
| first_sample = current_samples[0] | ||
| if first_sample.throughput is None: | ||
| task_throughput = self.calculate_task_throughput(task, current_samples, bucket_interval_secs) | ||
| task_throughput = self.calculate_task_throughput(task, current_samples, bucket_interval_secs, windowed=windowed) | ||
| else: | ||
| task_throughput = self.map_task_throughput(current_samples) | ||
| global_throughput[task].extend(task_throughput) | ||
|
|
||
| return global_throughput | ||
|
|
||
| def calculate_task_throughput(self, task, current_samples, bucket_interval_secs): | ||
| def calculate_task_throughput(self, task, current_samples, bucket_interval_secs, windowed=False): | ||
| task_throughput = [] | ||
|
|
||
| if task not in self.task_stats: | ||
|
|
@@ -1745,12 +1762,13 @@ def calculate_task_throughput(self, task, current_samples, bucket_interval_secs) | |
|
|
||
| if current.can_calculate_throughput(): | ||
| current.finish_bucket(count) | ||
| rate = current.windowed_throughput if windowed else current.throughput | ||
| task_throughput.append( | ||
| ( | ||
| sample.absolute_time, | ||
| sample.relative_time, | ||
| current.sample_type, | ||
| current.throughput, | ||
| rate, | ||
| # we calculate throughput per second | ||
| f"{sample.total_ops_unit}/s", | ||
| ) | ||
|
|
@@ -1762,12 +1780,13 @@ def calculate_task_throughput(self, task, current_samples, bucket_interval_secs) | |
| # interval (mainly needed to ensure we show throughput data in test mode) | ||
| if last_sample is not None and current.can_add_final_throughput_sample(): | ||
| current.finish_bucket(count) | ||
| rate = current.windowed_throughput if windowed else current.throughput | ||
| task_throughput.append( | ||
| ( | ||
| last_sample.absolute_time, | ||
| last_sample.relative_time, | ||
| current.sample_type, | ||
| current.throughput, | ||
| rate, | ||
| f"{last_sample.total_ops_unit}/s", | ||
| ) | ||
| ) | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.