-
Notifications
You must be signed in to change notification settings - Fork 36
Record and Use Engine Flags in Summarize/Effect-Size Tools #293
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
Merged
abrown
merged 5 commits into
bytecodealliance:main
from
posborne:record-and-use-engine-flags
Dec 8, 2025
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
92e600b
Allow benchmark names to be overriden
posborne 9663a64
Record engine_flags with measurement data
posborne 989927e
Update summarize/effect-size to use engine flags
posborne 3c81ea5
Fix issues raised by the tests, improve coverage
posborne 31bd2de
Use single field for sightglass_data::Engine
posborne 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
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||||||||||||||||||||||||||
| use crate::keys::KeyBuilder; | ||||||||||||||||||||||||||||||
| use anyhow::Result; | ||||||||||||||||||||||||||||||
| use sightglass_data::{EffectSize, Measurement, Phase, Summary}; | ||||||||||||||||||||||||||||||
| use std::{collections::BTreeSet, io::Write}; | ||||||||||||||||||||||||||||||
| use std::{borrow::Cow, collections::BTreeSet, io::Write}; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| /// Find the effect size (and confidence interval) of between two different | ||||||||||||||||||||||||||||||
| /// engines (i.e. two different commits of Wasmtime). | ||||||||||||||||||||||||||||||
|
|
@@ -25,14 +25,20 @@ pub fn calculate<'a>( | |||||||||||||||||||||||||||||
| significance_level, | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| let keys = KeyBuilder::all().engine(false).keys(measurements); | ||||||||||||||||||||||||||||||
| let keys = KeyBuilder::all() | ||||||||||||||||||||||||||||||
| .engine(false) | ||||||||||||||||||||||||||||||
| .engine_flags(false) | ||||||||||||||||||||||||||||||
| .keys(measurements); | ||||||||||||||||||||||||||||||
| let mut results = Vec::with_capacity(keys.len()); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| for key in keys { | ||||||||||||||||||||||||||||||
| let key_measurements: Vec<_> = measurements.iter().filter(|m| key.matches(m)).collect(); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // NB: `BTreeSet` so they're always sorted. | ||||||||||||||||||||||||||||||
| let engines: BTreeSet<_> = key_measurements.iter().map(|m| &m.engine).collect(); | ||||||||||||||||||||||||||||||
| let engines: BTreeSet<_> = key_measurements | ||||||||||||||||||||||||||||||
| .iter() | ||||||||||||||||||||||||||||||
| .map(|m| (&m.engine, &m.engine_flags)) | ||||||||||||||||||||||||||||||
| .collect(); | ||||||||||||||||||||||||||||||
| anyhow::ensure!( | ||||||||||||||||||||||||||||||
| engines.len() == 2, | ||||||||||||||||||||||||||||||
| "Can only test significance between exactly two different engines. Found {} \ | ||||||||||||||||||||||||||||||
|
|
@@ -41,17 +47,17 @@ pub fn calculate<'a>( | |||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| let mut engines = engines.into_iter(); | ||||||||||||||||||||||||||||||
| let engine_a = engines.next().unwrap(); | ||||||||||||||||||||||||||||||
| let engine_b = engines.next().unwrap(); | ||||||||||||||||||||||||||||||
| let (engine_a, engine_a_flags) = engines.next().unwrap(); | ||||||||||||||||||||||||||||||
| let (engine_b, engine_b_flags) = engines.next().unwrap(); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| let a: behrens_fisher::Stats = key_measurements | ||||||||||||||||||||||||||||||
| .iter() | ||||||||||||||||||||||||||||||
| .filter(|m| m.engine.as_ref() == engine_a) | ||||||||||||||||||||||||||||||
| .filter(|m| m.engine.as_ref() == engine_a && &m.engine_flags == engine_a_flags) | ||||||||||||||||||||||||||||||
| .map(|m| m.count as f64) | ||||||||||||||||||||||||||||||
| .collect(); | ||||||||||||||||||||||||||||||
| let b: behrens_fisher::Stats = key_measurements | ||||||||||||||||||||||||||||||
| .iter() | ||||||||||||||||||||||||||||||
| .filter(|m| m.engine.as_ref() == engine_b) | ||||||||||||||||||||||||||||||
| .filter(|m| m.engine.as_ref() == engine_b && &m.engine_flags == engine_b_flags) | ||||||||||||||||||||||||||||||
| .map(|m| m.count as f64) | ||||||||||||||||||||||||||||||
| .collect(); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -62,8 +68,10 @@ pub fn calculate<'a>( | |||||||||||||||||||||||||||||
| phase: key.phase.unwrap(), | ||||||||||||||||||||||||||||||
| event: key.event.unwrap(), | ||||||||||||||||||||||||||||||
| a_engine: engine_a.clone(), | ||||||||||||||||||||||||||||||
| a_engine_flags: engine_a_flags.clone(), | ||||||||||||||||||||||||||||||
| a_mean: a.mean, | ||||||||||||||||||||||||||||||
| b_engine: engine_b.clone(), | ||||||||||||||||||||||||||||||
| b_engine_flags: engine_b_flags.clone(), | ||||||||||||||||||||||||||||||
| b_mean: b.mean, | ||||||||||||||||||||||||||||||
| significance_level, | ||||||||||||||||||||||||||||||
| half_width_confidence_interval: ci, | ||||||||||||||||||||||||||||||
|
|
@@ -73,6 +81,18 @@ pub fn calculate<'a>( | |||||||||||||||||||||||||||||
| Ok(results) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| fn engine_label(engine: &str, engine_flags: &Option<Cow<str>>) -> String { | ||||||||||||||||||||||||||||||
| format!( | ||||||||||||||||||||||||||||||
| "{}{}", | ||||||||||||||||||||||||||||||
| engine, | ||||||||||||||||||||||||||||||
| if let Some(ef) = engine_flags { | ||||||||||||||||||||||||||||||
| format!(" ({ef})") | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| "".into() | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| format!( | |
| "{}{}", | |
| engine, | |
| if let Some(ef) = engine_flags { | |
| format!(" ({ef})") | |
| } else { | |
| "".into() | |
| } | |
| ) | |
| if let Some(ef) = engine_flags { | |
| format!("{engine} ({ef})") | |
| } else { | |
| format!("{engine}") | |
| } |
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.
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.
I debated whether to even bring this up, please take it or leave it: if we were to coalesce the engine path and engine flags into a single field, it seems like we might be able to avoid a lot of the "oh, let's also add flags in here too" kinds of changes. Perhaps we still want separate CSV columns for each part, but IIRC there is a way to flatten a
struct Engine { path: ..., flags: ... }out into separate columns. If so, using a single struct everywhere (with auto-derivedPartialEq, Eq, ...) could make your life easier in the future and simplify this PR.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.
And then just generating the label is a matter of
impl Display for Engine... but now I'm over-selling this suggestion.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.
@abrown I like this idea; it occurred to me that something like it could be a good approach as I continued to have to update more callsites with a_engine, b_engine, etc. I will take a pass at implementing the idea as it should simplify a good chunk of code (probably exchanging a bit of complexity around ser/de).
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.
Implemented in 31bd2de; things did get gross with ser/de as rust-csv doesn't support flattened structs. After trying a few approaches, I ended up just have private "Wire" versions of each of the data structs to handle dealing with that.
An alternative could have been to format the struct as a single field/string but I didn't love that idea, especially if we may want to process the data with external programs (that would then need to parse/split that column to get the individual pieces of data).
This will break ingest of existing csv that doesn't have headers -- I don't think that really exists in the wild.