Implement fast path for derive(PartialOrd) when deriving Ord#155598
Implement fast path for derive(PartialOrd) when deriving Ord#155598makai410 wants to merge 4 commits intorust-lang:mainfrom
derive(PartialOrd) when deriving Ord#155598Conversation
|
Changes to the code generated for builtin derived traits. cc @nnethercote |
|
rustbot has assigned @ShoyuVanilla. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| cx.dcx().span_bug(field.span, "not exactly 2 arguments in `derive(Ord)`"); | ||
| cx.dcx() | ||
| .span_bug(field.span, "not exactly 2 arguments in `derive(PartialOrd)`"); | ||
| }; |
There was a problem hiding this comment.
I think this is probably a copy-paste curse, so I changed that, not 100% sure though.
This comment has been minimized.
This comment has been minimized.
|
I can review this: r? @nnethercote cc @theemathas, who has made good comments on similar PRs in the past. |
This comment has been minimized.
This comment has been minimized.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Implement fast path for `derive(PartialOrd)` when deriving `Ord`
| resolutions: Vec<DeriveResolution>, | ||
| helper_attrs: Vec<(usize, IdentKey, Span)>, | ||
| // if this list keeps getting extended, we could use `bitflags`, | ||
| // something like what [`rustc_type_ir::flags::TypeFlags`] is doing. |
There was a problem hiding this comment.
We had multiple flags here in the past, and they indeed used flags, and one map in the resolver instead of two containers_deriving_(copy,ord) maps.
There was a problem hiding this comment.
There was a problem hiding this comment.
Thanks for providing the context. I was thinking about doing one more round of scanning derives to collect all flags such that it might solve #124794. I don't know if that had been discussed before, and if it did I'd really want to know the reason of why not doing that.
There was a problem hiding this comment.
one more round of scanning derives to collect all flags
If I correctly understand what you are talking about, it's a much worse hack and it cannot work correctly.
We already doing something like that to support deprecation lint legacy_derive_helpers, and that logic is going to be removed soon.
|
Similarly to the existing Moreover, the |
|
@bors try |
This comment has been minimized.
This comment has been minimized.
Implement fast path for `derive(PartialOrd)` when deriving `Ord`
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (803fd19): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 0.7%, secondary -3.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.8%, secondary 4.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.1%, secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 490.44s -> 500.217s (1.99%) |
|
Hmmm, so the perf result doesn't seem to be a strong performance reason? I'm fine with closing this. |
|
The change isn't necessarily going to speed up the compiler itself. "Generate tight code for derives" is a good goal in general. |
|
☔ The latest upstream changes (presumably #155796) made this pull request unmergeable. Please resolve the merge conflicts. |
View all comments
Closes: #155537
Unfortunately, this PR shares the same issue with #124794, which doesn't work when
derive(PartialOrd)is beforederive(Ord).