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

Small wins for formatting-related code #108043

Merged
merged 1 commit into from
Sep 18, 2023
Merged

Conversation

a1phyr
Copy link
Contributor

@a1phyr a1phyr commented Feb 14, 2023

This PR does two small wins in fmt code:

  • Override write_char for PadAdapter to use inner buffer's write_char
  • Override some write_fmt implementations to avoid avoid the additional indirection and vtable generated by the default impl.

@rustbot
Copy link
Collaborator

rustbot commented Feb 14, 2023

r? @m-ou-se

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 14, 2023
@rustbot
Copy link
Collaborator

rustbot commented Feb 14, 2023

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@a1phyr a1phyr changed the title Override fmt::Write::write_fmt for String and OsOstring Small wins for formatting-related code Feb 17, 2023
@bors
Copy link
Contributor

bors commented Feb 27, 2023

☔ The latest upstream changes (presumably #108538) made this pull request unmergeable. Please resolve the merge conflicts.

@m-ou-se
Copy link
Member

m-ou-se commented Feb 28, 2023

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 28, 2023
@bors
Copy link
Contributor

bors commented Feb 28, 2023

⌛ Trying commit ca28dfbb4b820b0e7cfc1fd6664bae9639c9bb8c with merge 8ad851c86fce5857555c1acdd0b2dd1a8f216b49...

@bors
Copy link
Contributor

bors commented Feb 28, 2023

☀️ Try build successful - checks-actions
Build commit: 8ad851c86fce5857555c1acdd0b2dd1a8f216b49 (8ad851c86fce5857555c1acdd0b2dd1a8f216b49)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8ad851c86fce5857555c1acdd0b2dd1a8f216b49): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.8% [0.8%, 0.8%] 1
Improvements ✅
(primary)
-0.3% [-0.3%, -0.3%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.3% [-0.3%, -0.3%] 1

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.7% [3.7%, 3.7%] 1
Improvements ✅
(primary)
-1.7% [-3.7%, -0.5%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.7% [-3.7%, -0.5%] 3

Cycles

This benchmark run did not return any relevant results for this metric.

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 28, 2023
@a1phyr
Copy link
Contributor Author

a1phyr commented Mar 7, 2023

I had a thought on this: instead of re-implementing fmt::Write::write_fmt for each type, could we directly specialize on T: Sized to give the better impl for all types that can coerce to dyn fmt::Write ?

@m-ou-se m-ou-se added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 1, 2023
@a1phyr a1phyr force-pushed the string_write_fmt branch from ca28dfb to 09fef6c Compare May 16, 2023 15:39
@rust-log-analyzer

This comment has been minimized.

@Dylan-DPC
Copy link
Member

@a1phyr any updates on the CI failure? thanks

@a1phyr a1phyr force-pushed the string_write_fmt branch from 09fef6c to 761603e Compare May 22, 2023 15:29
@Dylan-DPC Dylan-DPC added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 22, 2023
@a1phyr
Copy link
Contributor Author

a1phyr commented May 23, 2023

Ubuntu was down 😅

@a1phyr a1phyr force-pushed the string_write_fmt branch from 761603e to 24af417 Compare July 26, 2023 21:48
@workingjubilee
Copy link
Member

@bors try @rust-timer queue

Just trying to collect more data to help assess the runtime perf suite.

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 16, 2023
@dtolnay
Copy link
Member

dtolnay commented Sep 16, 2023

write_char by itself reproduces almost none of the difference. #115782 (comment)

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 16, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 17, 2023
@a1phyr
Copy link
Contributor Author

a1phyr commented Sep 17, 2023

I have rebased the PR on master so there is only the commit with specialization left.

@workingjubilee
Copy link
Member

Weird!

I think this was honestly pretty good solely on the strength of the binary size improvement seemingly across-the-board, nevermind the perf seemingly being not-bad.

@bors r+

@bors
Copy link
Contributor

bors commented Sep 17, 2023

📌 Commit 78846d1 has been approved by workingjubilee

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 17, 2023
@bors
Copy link
Contributor

bors commented Sep 17, 2023

⌛ Testing commit 78846d1 with merge 95d6ccc...

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 17, 2023
…bilee

Small wins for formatting-related code

This PR does two small wins in fmt code:
- Override `write_char` for `PadAdapter` to use inner buffer's `write_char`
- Override some `write_fmt` implementations to avoid avoid the additional indirection and vtable generated by the default impl.
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Checking toml v0.7.5
[RUSTC-TIMING] cargo_metadata test:false 1.748
[RUSTC-TIMING] toml test:false 0.806
 Documenting rustfmt-nightly v1.6.0 (/checkout/src/tools/rustfmt)
##[error]The runner has received a shutdown signal. This can happen when the runner service is stopped, or a manually started runner is canceled.
##[group]Clock drift check
  local time: Mon Sep 18 00:01:49 UTC 2023
  local time: Mon Sep 18 00:01:49 UTC 2023
Session terminated, killing shell... ...killed.
##[error]The operation was canceled.
Cleaning up orphan processes

@bors
Copy link
Contributor

bors commented Sep 18, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 18, 2023
@dtolnay
Copy link
Member

dtolnay commented Sep 18, 2023

Can't tell what failed.
@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 18, 2023
@bors
Copy link
Contributor

bors commented Sep 18, 2023

⌛ Testing commit 78846d1 with merge df99bc1...

@bors
Copy link
Contributor

bors commented Sep 18, 2023

☀️ Test successful - checks-actions
Approved by: workingjubilee
Pushing df99bc1 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 18, 2023
@bors bors merged commit df99bc1 into rust-lang:master Sep 18, 2023
11 checks passed
@rustbot rustbot added this to the 1.74.0 milestone Sep 18, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (df99bc1): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.3% [0.3%, 0.4%] 3
Improvements ✅
(primary)
-0.6% [-0.6%, -0.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.6% [-0.6%, -0.6%] 1

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
9.2% [9.2%, 9.2%] 1
Regressions ❌
(secondary)
4.0% [4.0%, 4.0%] 1
Improvements ✅
(primary)
-2.8% [-4.8%, -0.1%] 6
Improvements ✅
(secondary)
-3.2% [-3.2%, -3.2%] 1
All ❌✅ (primary) -1.1% [-4.8%, 9.2%] 7

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.2% [0.0%, 0.6%] 6
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.4%, -0.0%] 24
Improvements ✅
(secondary)
-0.7% [-1.3%, -0.2%] 2
All ❌✅ (primary) -0.0% [-0.4%, 0.6%] 30

Bootstrap: 636.108s -> 634.721s (-0.22%)
Artifact size: 318.40 MiB -> 318.13 MiB (-0.08%)

@rustbot rustbot removed the perf-regression Performance regression. label Sep 18, 2023
@workingjubilee
Copy link
Member

Hmm, that's slightly less good? but it still seems okay overall.

@a1phyr a1phyr deleted the string_write_fmt branch March 12, 2024 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.