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

Use serde to encode/decode various TOML formats #3864

Merged
merged 13 commits into from
Jun 9, 2024
Merged

Use serde to encode/decode various TOML formats #3864

merged 13 commits into from
Jun 9, 2024

Conversation

djc
Copy link
Contributor

@djc djc commented Jun 8, 2024

This saves a bunch of code (-190 lines) and is generally more idiomatic. It also saves about 8% of latency on proxy invocations, after (both best of 3 runs):

djc-2021 toml rustup $ RUSTUP_FORCE_ARG0=rustc hyperfine "./target/release/rustup-init --version"
Benchmark 1: ./target/release/rustup-init --version
  Time (mean ± σ):      32.6 ms ±   0.6 ms    [User: 23.3 ms, System: 5.5 ms]
  Range (min … max):    31.4 ms …  34.6 ms    86 runs

before:

djc-2021 master rustup $ RUSTUP_FORCE_ARG0=rustc hyperfine "./target/release/rustup-init --version"
Benchmark 1: ./target/release/rustup-init --version
  Time (mean ± σ):      35.3 ms ±   0.6 ms    [User: 25.6 ms, System: 5.8 ms]
  Range (min … max):    33.6 ms …  36.6 ms    79 runs

@djc djc requested a review from rami3l June 8, 2024 12:46
@djc djc force-pushed the toml branch 3 times, most recently from c1838e7 to 686defa Compare June 8, 2024 13:12
src/config.rs Outdated
Ok(())
})
}
_ => Err(RustupError::UnknownMetadataVersion(current_version).into()),
MetadataVersion::V12 => {
Copy link
Member

@rami3l rami3l Jun 9, 2024

Choose a reason for hiding this comment

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

To me it's clear that the happy path in the original code is for MetadataVersion::default(), but now it's for MetadataVersion::V12. I know at the moment being it's all the same, but the meaning being conveyed seems to be a bit different, and that might cause problems when the default value changes 🤔

Copy link
Contributor Author

@djc djc Jun 9, 2024

Choose a reason for hiding this comment

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

I've reverted the logic to something closer to what was originally there.

src/settings.rs Outdated Show resolved Hide resolved
src/dist/config.rs Outdated Show resolved Hide resolved
src/dist/config.rs Outdated Show resolved Hide resolved
Copy link
Member

@rami3l rami3l left a comment

Choose a reason for hiding this comment

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

Nice improvements overall! Somehow I thought we were using serde for such things already 🤣

@djc djc enabled auto-merge June 9, 2024 07:55
@djc djc added this pull request to the merge queue Jun 9, 2024
Merged via the queue into master with commit 81a7164 Jun 9, 2024
26 checks passed
@djc djc deleted the toml branch June 9, 2024 08:27
@rami3l rami3l added this to the 1.28.0 milestone Jun 9, 2024
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