-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Improve assert_eq! and assert_ne! #79100
Conversation
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
550d4de
to
f1e7052
Compare
Does this improves runtime performance?
I can't seemed to notice the difference in the assembly.
Looks nice but I wonder if we need 2x/4x the trait objects? Is it possible to have one |
The difference is not in the fast path, but in the panicking one.
The only formatting that change between |
Yes, but doesn't the current implementation makes it another function which doubles the code if a user use Not sure about the |
Diffing the two assembly outputs seemed to give me nothing, are you sure you posted the correct link? Or maybe I copied the wrong thing? |
Yes, it does. We can add an
Well, it could, but we definitely want to keep a separate generic function when there is no |
You don't have any difference between |
think that @pickfire expected something like this https://rust.godbolt.org/z/4co4f1 where there is a diff between two editors that implement the same thing in two ways. I think that I split @a1phyr:s example correct in that godbolt link. |
@andjo403 Oh, I see. I didn't know you could produce diffs like that in Godbold. |
0c9f27d
to
5d79f11
Compare
This is very strange, some tests fail but seem totally unrelated (eg this test), and I'm not sure what to do about them. Anyway, let's see if it improves compile time @bors try @rust-timer queue |
Insufficient permissions to issue commands to rust-timer. |
@a1phyr: 🔑 Insufficient privileges: not in try users |
1 similar comment
@a1phyr: 🔑 Insufficient privileges: not in try users |
Insufficient permissions to issue commands to rust-timer. |
@andjo403 Oh, I didn't know you can produce diff in godbolt. It seemed like the assembly lines increased. |
Updated godbolt to include 6 functions, it seemed like the number of assembly lines increased, removing Merging the one with |
Can someone start rust-timer to see if this has a positive impact on build time ? And also, does someone has a clue what makes this test fail ? It does not seem related to my changes. |
@pickfire please don't ping me specifically for perf runs, there's a Zulip stream for that. @a1phyr are you sure it makes sense to measure the perf before fixing the tests? Your fix might itself have a perf impact. |
I think the only changes that I have left to do are tests themselves (eg changing a mir output), but you're right that we should wait them to be fixed. |
@bors try @rust-timer queue |
Awaiting bors try build completion |
⌛ Trying commit 0dbf6d0f280da53dfadc453a699d01b577a33a4b with merge 7827eb84fe5a82fab0dcc16f6eb5121188f2846e... |
Looking at last bors failure, it is likely that you will have to set |
Thanks ! I didn't know about the The test should pass now. |
@m-ou-se I don't think I can retry myself, could you do it please ? |
Oh sorry, missed your previous message. @bors r+ rollup=maybe |
📌 Commit 7333759 has been approved by |
Note: this should probably be |
@bors rollup=never |
also @m-ou-se |
Oh I'm aware of |
☀️ Test successful - checks-actions |
A job failed! Check out the build log: (web) (plain) Click to see the possible cause of the failure (guessed by this bot)
|
Some(args) => panic!( | ||
r#"assertion failed: `(left {} right)` | ||
left: `{:?}`, | ||
right: `{:?}: {}`"#, |
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.
Was the change that moves : {}
inside the `
quotes intentional?
The panic message now looks suboptimal to me: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=0cbe6c5669d0b7458c6d9f67a3ea7518
Nightly
right: `3: 1 + 1 should definitely be 3`', src/main.rs:2:5
Stable
right: `3`: 1 + 1 should definitely be 3', src/main.rs:2:5
(In case it was unintentional, I have a patch.)
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.
@hyd-dev oh, good catch! Can you send that patch as a PR? (Feel free to assign me with r? @m-ou-se
.)
Fix panic message of `assert_failed_inner` cc rust-lang#79100 (comment) r? `@m-ou-se`
Fix panic message of `assert_failed_inner` cc rust-lang#79100 (comment) r? ``@m-ou-se``
Debug-print result when an unstable fingerprint is detected Helps with issues like rust-lang#83311 I had previously tried to do this in rust-lang#80692, but it had a significant performance impact (even though the code was never actually run). Hopefully, this will be better now that rust-lang#79100 has been merged.
This PR improves
assert_eq!
andassert_ne!
by moving the panicking code in an external function.It does not change the fast path, but the move of the formatting in the cold path (the panic) may have a positive effect on in instruction cache use and with inlining.
Moreover, the use of trait objects instead of generic may improve compile times for
assert_eq!
-heavy code.Godbolt link:
https://rust.godbolt.org/z/TYa9MTUpdated: https://rust.godbolt.org/z/bzE84x