-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Simplify rustc_serialize by dropping support for decoding into JSON #93839
Simplify rustc_serialize by dropping support for decoding into JSON #93839
Conversation
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
@bors try @rust-timer queue -- I'm interested to see if the simplification has any effect on compiler bootstrap times or performance. Follows on groundwork laid by #93681, #93680 to remove JSON usage from a few places. It may merit an MCP, which likely would replicate the PR description fairly closely, but will leave that decision up to the reviewer. |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 5c90ffea61c1b2fb8b732e56afa71dcc1cdeab87 with merge 413eebf76cb8e173694bdcc35c93c55542ec76a0... |
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
Queued 413eebf76cb8e173694bdcc35c93c55542ec76a0 with parent e7aca89, future comparison URL. |
Finished benchmarking commit (413eebf76cb8e173694bdcc35c93c55542ec76a0): comparison url. Summary: This benchmark run shows 6 relevant improvements 🎉 but 9 relevant regressions 😿 to instruction counts.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. 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 led to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never |
5c90ffe
to
eac0eae
Compare
This comment has been minimized.
This comment has been minimized.
eac0eae
to
6674f0f
Compare
I'm pretty sure the small amount of regressions (and improvements, for that matter) in compiler performance is just optimizer noise due to a bunch of different inlining decisions as things get shuffled earlier or later due to simpler Decode impls. On the other hand, the compiler bootstrap performance improvement is likely not noise, and is a nice ~6 seconds overall. IMO the cleanup here is well-motivated regardless of the comparatively minor regressions in some benchmarks, and primarily incr-unchanged benchmarks at that. |
Related: #85993 |
Yes, this is intentionally intended as a version that does not cause any practical impact (i.e., no features removed) with the goal of enabling it to land without too much discussion that #85993 requires due to dropping support for -Zast-json and the like. |
6674f0f
to
5b6932d
Compare
r? @cjgillot |
I have a weak preference for preserving |
@bors r=nnethercote read_seq and read_map are both reading just a length from the buffer prior to being called with the current impl, which means that they're tail-calling the passed closure, and I at least find it a little clearer to read the read_usize in plain text (inlined, sort of) than not. I also think that as we go further along this path (e.g., moving to a Decoder struct) that calculus might shift a little, particularly if some of the users of read_seq start wanting to do something like read_seq_leb128 or so. |
📌 Commit 5b6932da8c30c5c010e6291b5fc758954a2f3700 has been approved by |
@bors ping |
😪 I'm awake I'm awake |
@bors retry auto (dist-aarch64-apple, ./x.py dist --stage 2, --build=x86_64-apple-darwin --host=aarch64-apple... |
⌛ Testing commit c6ad61a with merge 6bdcc5730ff1028182339ecf33e8cf98464128a2... |
💔 Test failed - checks-actions |
@bors retry dist-apple-various didn't start |
☀️ Test successful - checks-actions |
Finished benchmarking commit (58a721a): comparison url. Summary: This benchmark run shows 3 relevant improvements 🎉 but 6 relevant regressions 😿 to instruction counts.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression |
Cleanup a few Decoder methods This is just some simple follow up to rust-lang#93839. r? `@nnethercote`
This PR currently bundles two (somewhat separate) tasks.
First, it removes the JSON Decoder trait impl, which permitted going from JSON to Rust structs. For now, we keep supporting JSON deserialization, but only to
Json
(an equivalent of serde_json::Value). The primary hard to remove user there is for custom targets -- which need some form of JSON deserialization -- but they already have a custom ad-hoc pass for moving from Json to a Rust struct.A comment there suggests that it would be impractical to move them to a Decodable-based impl, at least without backwards compatibility concerns. I suspect that if we were widely breaking compat there, it would make sense to use serde_json at this point which would produce better error messages; the types in rustc_target are relatively isolated so we would not particularly suffer from using serde_derive.
The second part of the PR (all but the first commit) is to simplify the Decoder API by removing the non-primitive
read_*
functions. These primarily add indirection (through a closure), which doesn't directly cause a performance issue (the unique closure types essentially guarantee monomorphization), but does increase the amount of work rustc and LLVM need to do. This could be split out to a separate PR, but is included here in part to help motivate the first part.Future work might consist of:
Vec<u8>
, but other types which could benefit don't today.Highly recommend review with whitespace changes off, as the removal of closures frequently causes things to be de-indented.