-
Notifications
You must be signed in to change notification settings - Fork 157
Generalize metrics #1338
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
Generalize metrics #1338
Conversation
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 think there are certainly some metric types that we consider first class (e.g., instructions, max-rss, and cycles) while the others we don't normally have much logic associated with and it's fine to just pass around the string. It might make sense to limit the enum to the first class metric types and then have an Other
variant for everything else
So currently we use three metrics as "first-class": instructions, cycles and max RSS. I could use these as enum variants and leave the rest as (There is |
A custom deserializer should be easy with |
Oh, I thought that we couldn't use that because we need something like that for the whole enum, but I can just probably use a deserializer function for the single variant and count on the fact that |
Hmm, maybe it's not so straightforward after all. Like this: fn parse_custom_metric<'a, D: Deserializer<'a>>(deserializer: D) -> Result<String, D::Error> {
String::deserialize(deserializer)
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum Metric {
#[serde(rename = "instructions:u")]
Instructions,
#[serde(rename = "cycles:u")]
Cycles,
#[serde(rename = "max-rss")]
MaxRSS,
#[serde(deserialize_with = "parse_custom_metric")]
Custom(String),
} it does not parse Like this: #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Metric {
#[serde(rename = "instructions:u")]
Instructions,
#[serde(rename = "cycles:u")]
Cycles,
#[serde(rename = "max-rss")]
MaxRSS,
#[serde(deserialize_with = "parse_custom_metric")]
Custom(String),
} it parses everything as I'm out of ideas of how to do this on the field level, so I'm inclined to write a custom deserializer for the whole struct, unless you see a better way. |
A custom deserializer seems fine to me. |
I implemented it with a custom deserializer. |
We decided with @Mark-Simulacrum to just explicitly enumerate the set of known metrics for now and expand them in the future. |
Hm, it looks like the database check is no longer succeeding, but it's also failing on master? Going to go ahead and remove it from the branch protection rule for now, and we can try to investigate and fix it in the future. |
My recent PR (#1322) has broken displaying various metrics in the compare page (#1337). This PR adds all (currently) known metric variants to the
Metric
enum.