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 iai adapter parser #98

Merged
merged 9 commits into from
Jun 5, 2023
Merged

Conversation

osiewicz
Copy link
Contributor

@osiewicz osiewicz commented Apr 2, 2023

This is still a bit WIP, as I intend to add new tests akin to those in criterion adapter.

(Partially?) solves #82

@epompeii epompeii changed the title Add iai adapter Draft: Add iai adapter Apr 3, 2023
@epompeii epompeii changed the base branch from main to devel April 3, 2023 14:03
Copy link
Member

@epompeii epompeii left a comment

Choose a reason for hiding this comment

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

Great start!

I marked this as Draft since it is still WIP.
I also changed the target branch to devel. Since this is the first real PR, it will make it easier to target devel given how I have CI set up. 😃
So you may want to do a merge or rebase from devel to clear up some of the minor diffs there.

lib/bencher_adapter/src/adapters/rust/iai.rs Show resolved Hide resolved
lib/bencher_adapter/src/adapters/rust/iai.rs Outdated Show resolved Hide resolved
@@ -48,6 +55,31 @@ impl AdapterResults {
THROUGHPUT_RESOURCE_ID.clone() => json_metric
}
},
AdapterMetricKind::Instructions(json_metric) => {
Copy link
Member

Choose a reason for hiding this comment

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

This helper function is for creating one-to-one benchmark name to metric kind relationships.
That is not what we want here. We want a one-to-many benchmark name to metric kind relation. That is one benchmark name with multiple metric kinds underneath/inside it.

This should be a separate helper function. Something like:

pub fn new_multi(benchmark_metrics: Vec<(BenchmarkName, HashSet<AdapterMultiMetricKind>)>) -> Option<Self>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, that sounds good. It seems like we'll have to change AdapterResults as well, since it can only represent a single benchmark_name -> result mapping. Does that sound good?

Copy link
Member

@epompeii epompeii Apr 10, 2023

Choose a reason for hiding this comment

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

We shouldn't have to change AdapterResults as it is a BenchmarkName -> AdapterMetrics and AdapterMetrics is MetricKind -> JsonMetric. So the data structure itself does not need to change. There just needs to be multiple keys in the AdapterMetrics map (instead of just one).

Hence the new helper function for AdapterResults. This will produce an AdaperResults containing an AdapterMetics that contains all of the Metric Kinds for Iai.

@@ -26,6 +28,11 @@ impl From<ResultsMap> for AdapterResults {
pub enum AdapterMetricKind {
Latency(JsonMetric),
Throughput(JsonMetric),
Instructions(JsonMetric),
Copy link
Member

Choose a reason for hiding this comment

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

These should be split into their own enum (see comment below).

Something like: AdapterMultiMetricKind

}

fn parse_iai_lines(lines: &[&str]) -> Option<(BenchmarkName, Vec<AdapterMetricKind>)> {
if lines.len() != 6 {
Copy link
Member

Choose a reason for hiding this comment

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

I get that this length check should make it impossible for the below indexing to panic, but I would prefer to use a single line pattern match instead.

let (Some(benchmark_name_line), Some(instructions_line), ...) = (lines.get(0), lines.get(1), ...) else {
    return None;
}

lib/bencher_adapter/src/adapters/rust/iai.rs Outdated Show resolved Hide resolved
lib/bencher_adapter/src/adapters/rust/iai.rs Outdated Show resolved Hide resolved
lib/bencher_adapter/src/adapters/rust/iai.rs Outdated Show resolved Hide resolved
.expect("Failed to parse metric kind slug."),
)
});
pub const L1_ACCESSES_UNITS_STR: &str = "accesses";
Copy link
Member

Choose a reason for hiding this comment

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

Maybe just have a single ACCESSES_UNITS_STR since they are all the same unit value.

osiewicz added 2 commits April 3, 2023 17:02
- Parse results as u64 instead of f64.
- Do not accept JsonAverage::Mean from Settings.
- Rewrite line unpacking in parse_iai_lines.
- Use less verbose syntax for conversion to MetricKind.
- Remove parse_from_header in favor of parsing the header directly in
  parse_iai_metric.
.expect("Failed to parse metric kind slug."),
)
});
pub const L1_ACCESSES_UNITS_STR: &str = ACCESSES_UNITS_STR;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think these aliases are necessary, just using ACCESSES_UNITS_STR below should be fine.

@epompeii epompeii changed the title Draft: Add iai adapter Add iai adapter parser Jun 5, 2023
@epompeii epompeii merged commit 76f5a9a into bencherdev:devel Jun 5, 2023
@epompeii
Copy link
Member

@osiewicz Thank you for all of work work here!
I went ahead and merged things in and pushed thing across the finish line.
💯 x thank you for being the first community contributor to Bencher!

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.

2 participants