Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Move Throughput into sc-sysinfo #12368

Merged
merged 45 commits into from
Nov 4, 2022

Conversation

Szegoo
Copy link
Contributor

@Szegoo Szegoo commented Sep 27, 2022

Prepares for #12017

Polkadot address: 126X27SbhrV19mBFawys3ovkyBS87SGfYwtwa8J2FjHrtbmA

@ggwpez
Copy link
Member

ggwpez commented Sep 28, 2022

I think it is also fine to split the issue into two MRs, depending on your preferences.
The changes here already make sense to have on their own.

@Szegoo Szegoo marked this pull request as ready for review September 28, 2022 20:14
@Szegoo
Copy link
Contributor Author

Szegoo commented Sep 28, 2022

I think it is also fine to split the issue into two MRs, depending on your preferences. The changes here already make sense to have on their own.

Sure, that makes sense.

@Szegoo Szegoo changed the title Warn validators with slow hardware Move Throughput into sc-sysinfo Sep 28, 2022
@ggwpez
Copy link
Member

ggwpez commented Sep 28, 2022

I can review earliest on Friday. But maybe @koute wants to, it touches your code :)

You are only reafactoring code as preparation for #12017, right?
Then please update the issue description to not Close the issue.
We also need to ensure that this does not break telemetry.

@Szegoo
Copy link
Contributor Author

Szegoo commented Sep 28, 2022

You are only reafactoring code as preparation for #12017, right? Then please update the issue description to not Close the issue. We also need to ensure that this does not break telemetry.

Yes, this is only preparation for #12017, I changed the description now. The CI doesn't seem happy, I will do some minor fixes on this.

client/sysinfo/src/lib.rs Outdated Show resolved Hide resolved
@bkchr
Copy link
Member

bkchr commented Sep 28, 2022

I also don't really get why we need Throughput there. @ggwpez can you give more context?

@ggwpez
Copy link
Member

ggwpez commented Sep 29, 2022

I also don't really get why we need Throughput there. @ggwpez can you give more context?

The measurement of the performance at startup runs in sc-sysinfo. So if we now want to compare the results of that to anything, we need the Throughput types to have nicer compare logic and formatting in the final output. The type only exists to make it possible to deserialize from JSON with a unit suffix.
I just originally did not put it in sy-sysinfo to keep the sc- crate small, since it was not needed.

client/sysinfo/src/sysinfo.rs Outdated Show resolved Hide resolved
client/sysinfo/src/sysinfo.rs Show resolved Hide resolved
client/sysinfo/src/sysinfo.rs Outdated Show resolved Hide resolved
client/sysinfo/src/sysinfo.rs Outdated Show resolved Hide resolved
client/sysinfo/src/sysinfo.rs Outdated Show resolved Hide resolved
client/sysinfo/src/lib.rs Outdated Show resolved Hide resolved
@Szegoo Szegoo requested review from ggwpez and bkchr and removed request for ggwpez October 19, 2022 10:19
@@ -45,6 +101,7 @@ pub struct Requirement {
/// The metric to measure.
pub metric: Metric,
/// The minimal throughput that needs to be archived for this requirement.
#[serde(serialize_with = "serialize_throughput", deserialize_with = "deserialize_throughput")]
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to support deserialize at all? @ggwpez?

Copy link
Member

Choose a reason for hiding this comment

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

Ahh, now I see. Do we really need to serialize with the unit attached? I don't think we should do this. You can just serialize as mib and fine.

Copy link
Contributor Author

@Szegoo Szegoo Oct 20, 2022

Choose a reason for hiding this comment

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

I don't think we should do this, the reference_hardware.json has values specified in other units also, of course, we can probably change that, but isn't it nicer to have the biggest possible unit used? @bkchr

Copy link
Member

Choose a reason for hiding this comment

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

Yea the only reason to have units was the maintainability of that file. Although if we add an option to auto-generate it, then it should be fine either way.

Copy link
Member

Choose a reason for hiding this comment

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

I mean normally you would just do it in bytes and fine. Like having there Mibs etc also requires documentation, as no one knows which kind of units are supported.

Comment on lines 33 to 42
let mut map = serializer.serialize_map(Some(1))?;
let (value, unit) = t.normalize();
let unit_as_str = match unit {
Unit::GiBs => "GiBs",
Unit::MiBs => "MiBs",
Unit::KiBs => "KiBs",
};

map.serialize_entry(&unit_as_str, &value)?;
map.end()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let mut map = serializer.serialize_map(Some(1))?;
let (value, unit) = t.normalize();
let unit_as_str = match unit {
Unit::GiBs => "GiBs",
Unit::MiBs => "MiBs",
Unit::KiBs => "KiBs",
};
map.serialize_entry(&unit_as_str, &value)?;
map.end()
let (value, unit) = t.normalize();
serializer.serialize_str(&format!("{} {}", value, unit))

Copy link
Contributor

Choose a reason for hiding this comment

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

@bkchr I explicitly requested that this will be done the way it is now. (:

See these comments why:

#12368 (comment)
#12368 (comment)

Maybe a comment in the code would be good why this match is currently duplicated? Or just don't serialize/deserialize the units at all and keep it all in MB/s (but that's up to @ggwpez).

Copy link
Member

Choose a reason for hiding this comment

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

Same argument as above - just the maintainability of the json file. Since having units is self explanatory, otherwise it needs docs to explain what it means.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm okay, I'm not really convinced of having the mibs etc be part of the json. However, I also don't really care. If @ggwpez is happy, he can approve and I will not complain.

@ggwpez ggwpez added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Oct 20, 2022
Copy link
Member

@ggwpez ggwpez left a comment

Choose a reason for hiding this comment

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

I dont have a strong opinion on the serialization stuff.

client/sysinfo/src/sysinfo.rs Outdated Show resolved Hide resolved
Co-authored-by: Oliver Tale-Yazdi <[email protected]>
@Szegoo
Copy link
Contributor Author

Szegoo commented Oct 20, 2022

@ggwpez So what is the final decision then?

@ggwpez
Copy link
Member

ggwpez commented Oct 20, 2022

@ggwpez So what is the final decision then?

Okay then lets remove the unit from the serialization. Less code - less bugs.

@Szegoo
Copy link
Contributor Author

Szegoo commented Oct 20, 2022

Okay then lets remove the unit from the serialization. Less code - less bugs.

@ggwpez What should we do with reference_hardware.json then?

Edit: wouldn't auto-generating it result in even more code?

@ggwpez
Copy link
Member

ggwpez commented Oct 29, 2022

@ggwpez What should we do with reference_hardware.json then?

Change it so that it works with the new format.

Edit: wouldn't auto-generating it result in even more code?

We need auto-generation at one point anyway, as manual editing is error-prone and not straight forward.

@Szegoo
Copy link
Contributor Author

Szegoo commented Oct 29, 2022

@ggwpez So I assume we should use MiBs in the reference_hardware.json then?

@bkchr
Copy link
Member

bkchr commented Nov 3, 2022

@ggwpez can we merge this?

@ggwpez
Copy link
Member

ggwpez commented Nov 4, 2022

bot merge

@paritytech-processbot
Copy link

Waiting for commit status.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants