Repository navigation
perf: emit field names as a concatenated string in derive(Debug) for structs - #164726
panstromek wants to merge 15 commits into
Conversation
|
perf test for field names of large structs. This probably won't be as visible, there's not that many of those. I'll try to pick only benchmarks that that have those + 2 other ones as a spot check. @bors try |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Use concatenated string in more debug derives
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (455d3ee): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking 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. @bors rollup=never rustc-perf 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 -2.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -0.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: missing data |
|
Nice, looks better than I expected. This makes sense, the best result is |
f43fa07 to
219cd16
Compare
|
r? nnethercote Are you ok if I keep assigning you these things or should I let rustbot roll the dice? I've been assigning you almost everything lately, but that's just because I work on things you implemented and I try to pick reviewer based on who worked on the relevant code. |
|
Changes to the code generated for builtin derived traits. cc @nnethercote |
|
Nice idea! Can you do the same thing for No problem with the reviews. I always ask an appropriate person directly instead of letting the random choice happen. |
Oh, that's another question I have. I was going to try that in a separate PR to separate the impact, do you prefer to do all of them at once? |
|
It's such a closely related change, might as well do it here. Can be a separate commit if you want. |
|
Let's see how this works out for smaller structs. I'm a bit worried tbh. I think this should be better as far as the generated code goes, because the MIR will be smaller, but there's also more Symbol manipulation and interning, so it might not be so clear cut. @bors try @rust-timer queue Note: I went a bit further and concatenated struct name with the fields as well. This was simpler to do in the |
This comment has been minimized.
This comment has been minimized.
perf: emit field names as a concatenated string in derive(Debug) for large structs
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…large structs This improves compile time for crates that derive Debug for large structs (e.g., ripgrep). It also reduces metadata size for some of those.
This avoids one more string and makes the derive code slightly nicer as we don't have to track whether we're on last item
We do this by changing the variable to a closure and only call it when it's needed
2ec69fe to
4719ede
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
rebased @rustbot ready |
|
@bors r+ |
View all comments
Similar idea as #162535 and previous attempts.
Again, I also noticed that no test fails when I mess up the string, so I added a test case.