feat(rustdoc-json): Add optional support for rkyv (de)serialization#153283
feat(rustdoc-json): Add optional support for rkyv (de)serialization#153283rust-bors[bot] merged 2 commits intorust-lang:mainfrom
Conversation
|
rustdoc-json-types is a public (although nightly-only) API. If possible, consider changing |
|
|
This comment has been minimized.
This comment has been minimized.
6cc4c8b to
e357584
Compare
|
|
||
| #[cfg(feature = "rkyv_0_8")] | ||
| mod rkyv { | ||
| use std::fmt::Debug; |
There was a problem hiding this comment.
These tests don't run. When I applied
diff --git a/src/rustdoc-json-types/tests.rs b/src/rustdoc-json-types/tests.rs
index e878350e43b..258c22304c3 100644
--- a/src/rustdoc-json-types/tests.rs
+++ b/src/rustdoc-json-types/tests.rs
@@ -41,6 +41,11 @@ fn test_union_info_roundtrip() {
#[cfg(feature = "rkyv_0_8")]
mod rkyv {
+ #[test]
+ fn definenly_fails() {
+ panic!("at least the rkyv tests were ran");
+ }
+
use std::fmt::Debug;
use rkyv::Archive;Running ./x test ./src/rustdoc-json-types/ still passed.
The fix (I think) is to enable this feature in bootsrap:
diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs
index 88f10775333..ab1d2b8a24b 100644
--- a/src/bootstrap/src/core/build_steps/test.rs
+++ b/src/bootstrap/src/core/build_steps/test.rs
@@ -3302,7 +3302,7 @@ fn run(self, builder: &Builder<'_>) {
builder.kind,
"src/rustdoc-json-types",
SourceType::InTree,
- &[],
+ &["rkyv_0_8".to_owned()],
);
// FIXME: this looks very wrong, libtest doesn't accept `-C` arguments and the quotes are fishy.(CC @jieyouxu, is this ok to do?)
There was a problem hiding this comment.
Apologies, I had only tested the crate directly via local cargo test, under the implicit assumption that the testing infrastructure would automatically pick up feature flags for matrix testing.
I've added the feature flag to the bootstrap script, let me know if other changes are needed.
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
|
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Thanks, I hope this helps perf.
r=me with commits squashed, and when someone from T-bootstrap signs off that 39f7f0d is ok.
40d35e9 to
1d81c50
Compare
|
Commits have been squashed @aDotInTheVoid. What's the best way to get a reviewer from T-bootstrap (or is your tag in the thread enough)? |
|
I asked on zulip (#t-infra/bootstrap > Review Request: Adding a feature in a test step.). Seems fine. (Sorry, I should've made that clear here). @bors r+ rollup |
Adds support for rust-lang/rust#153283
…=aDotInTheVoid feat(rustdoc-json): Add optional support for rkyv (de)serialization ## Motivation The JSON documents produced by `rustdoc-json` are _big_. More often than not, tools need to access a small fraction of that output—e.g. a couple of types from a transitive dependency, or a subset of the fields on a given `rustdoc-json-types` type. Using a binary (de)serialization format and a cache helps to drive down the performance cost of deserialization: you invoke `rustdoc-json` to get the JSON output you need, re-serialize it using a more perfomant format as target (e.g. `bincode` or `postcard`) and thus amortize the cost of future queries that hit the persistent cache rather than `rustdoc-json`. This is _better_, but still not great: the deserialization cost for crates like `std` still shows up prominently in flamegraphs. ## An Alternative Approach: rkyv `rkyv` provides a different opportunity: you avoid paying the deserialization cost _upfront_ thanks to [zero-copy deserialization](https://rkyv.org/zero-copy-deserialization.html). You're often able to determine if you need a certain entry from the JSON document using the archived version of that type, thus incurring the full deserialization cost only for the subset of items you actually need ([example](LukeMathWalker/pavex@d067e7e)). ## The Change This PR adds support for `rkyv` behind a feature flag (`rkyv_0_8`). For most types, it's a straight-forward `derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)` annotation. For co-recursive types, we need to adjust the generated bounds, using the techniques from [`rkyv`'s JSON example](https://github.com/rkyv/rkyv/blob/985b0230a0b9cb9fce4a4ee9facb6af148e27c8e/rkyv/examples/json_like_schema.rs). I have added new round-trip tests to ensure `rkyv` works as expected. r? @aDotInTheVoid
|
This pull request was unapproved. This PR was contained in a rollup (#153625), which was unapproved. |
|
There was a failure due to |
|
Requested reviewer is already assigned to this pull request. Please choose another assignee. |
|
I assume then that the right incantation is: @rustbot ready |
This comment has been minimized.
This comment has been minimized.
feat(rustdoc-json): Add optional support for rkyv (de)serialization try-job: dist-x86_64-linux-alt
|
💔 Test for 11041de failed: CI. Failed job:
|
|
That's github CI being funny, not this PRs fault... |
|
A job failed! Check out the build log: (web) (plain enhanced) (plain) Click to see the possible cause of the failure (guessed by this bot) |
…=aDotInTheVoid feat(rustdoc-json): Add optional support for rkyv (de)serialization ## Motivation The JSON documents produced by `rustdoc-json` are _big_. More often than not, tools need to access a small fraction of that output—e.g. a couple of types from a transitive dependency, or a subset of the fields on a given `rustdoc-json-types` type. Using a binary (de)serialization format and a cache helps to drive down the performance cost of deserialization: you invoke `rustdoc-json` to get the JSON output you need, re-serialize it using a more perfomant format as target (e.g. `bincode` or `postcard`) and thus amortize the cost of future queries that hit the persistent cache rather than `rustdoc-json`. This is _better_, but still not great: the deserialization cost for crates like `std` still shows up prominently in flamegraphs. ## An Alternative Approach: rkyv `rkyv` provides a different opportunity: you avoid paying the deserialization cost _upfront_ thanks to [zero-copy deserialization](https://rkyv.org/zero-copy-deserialization.html). You're often able to determine if you need a certain entry from the JSON document using the archived version of that type, thus incurring the full deserialization cost only for the subset of items you actually need ([example](LukeMathWalker/pavex@d067e7e)). ## The Change This PR adds support for `rkyv` behind a feature flag (`rkyv_0_8`). For most types, it's a straight-forward `derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)` annotation. For co-recursive types, we need to adjust the generated bounds, using the techniques from [`rkyv`'s JSON example](https://github.com/rkyv/rkyv/blob/985b0230a0b9cb9fce4a4ee9facb6af148e27c8e/rkyv/examples/json_like_schema.rs). I have added new round-trip tests to ensure `rkyv` works as expected. r? @aDotInTheVoid
…uwer Rollup of 14 pull requests Successful merges: - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`) - #152457 (Pass -pg to linker when using -Zinstrument-mcount) - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks) - #153471 (Refactor `ActiveJobGuard`) - #153595 (`QueryLatch` cleanups) - #153653 (scalable vector: type renames and simple checks) - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself) - #153283 (feat(rustdoc-json): Add optional support for rkyv (de)serialization) - #153479 (Add rationale for intentional potential_query_instability allows) - #153533 (Fix LegacyKeyValueFormat report from docker build: miscellaneous) - #153600 (add test for proc-macros with custom panic payloads) - #153643 (Avoid projection-only suggestions for inherent assoc types) - #153657 (triagebot: remove myself from some mention groups) - #153659 (Mark an unreachable match arm as such)
…uwer Rollup of 13 pull requests Successful merges: - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`) - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks) - #153471 (Refactor `ActiveJobGuard`) - #153595 (`QueryLatch` cleanups) - #153653 (scalable vector: type renames and simple checks) - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself) - #153283 (feat(rustdoc-json): Add optional support for rkyv (de)serialization) - #153479 (Add rationale for intentional potential_query_instability allows) - #153533 (Fix LegacyKeyValueFormat report from docker build: miscellaneous) - #153600 (add test for proc-macros with custom panic payloads) - #153643 (Avoid projection-only suggestions for inherent assoc types) - #153657 (triagebot: remove myself from some mention groups) - #153659 (Mark an unreachable match arm as such)
…uwer Rollup of 13 pull requests Successful merges: - #149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`) - #153143 (Allow `./x test` to run tests without doc tests and without benchmarks) - #153471 (Refactor `ActiveJobGuard`) - #153595 (`QueryLatch` cleanups) - #153653 (scalable vector: type renames and simple checks) - #152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself) - #153283 (feat(rustdoc-json): Add optional support for rkyv (de)serialization) - #153479 (Add rationale for intentional potential_query_instability allows) - #153533 (Fix LegacyKeyValueFormat report from docker build: miscellaneous) - #153600 (add test for proc-macros with custom panic payloads) - #153643 (Avoid projection-only suggestions for inherent assoc types) - #153657 (triagebot: remove myself from some mention groups) - #153659 (Mark an unreachable match arm as such)
Rollup merge of #153283 - LukeMathWalker:add-rkyv-support, r=aDotInTheVoid feat(rustdoc-json): Add optional support for rkyv (de)serialization ## Motivation The JSON documents produced by `rustdoc-json` are _big_. More often than not, tools need to access a small fraction of that output—e.g. a couple of types from a transitive dependency, or a subset of the fields on a given `rustdoc-json-types` type. Using a binary (de)serialization format and a cache helps to drive down the performance cost of deserialization: you invoke `rustdoc-json` to get the JSON output you need, re-serialize it using a more perfomant format as target (e.g. `bincode` or `postcard`) and thus amortize the cost of future queries that hit the persistent cache rather than `rustdoc-json`. This is _better_, but still not great: the deserialization cost for crates like `std` still shows up prominently in flamegraphs. ## An Alternative Approach: rkyv `rkyv` provides a different opportunity: you avoid paying the deserialization cost _upfront_ thanks to [zero-copy deserialization](https://rkyv.org/zero-copy-deserialization.html). You're often able to determine if you need a certain entry from the JSON document using the archived version of that type, thus incurring the full deserialization cost only for the subset of items you actually need ([example](LukeMathWalker/pavex@d067e7e)). ## The Change This PR adds support for `rkyv` behind a feature flag (`rkyv_0_8`). For most types, it's a straight-forward `derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)` annotation. For co-recursive types, we need to adjust the generated bounds, using the techniques from [`rkyv`'s JSON example](https://github.com/rkyv/rkyv/blob/985b0230a0b9cb9fce4a4ee9facb6af148e27c8e/rkyv/examples/json_like_schema.rs). I have added new round-trip tests to ensure `rkyv` works as expected. r? @aDotInTheVoid
…nathanBrouwer Rollup of 13 pull requests Successful merges: - rust-lang#149130 (Implement coercions between `&pin (mut|const) T` and `&(mut) T` when `T: Unpin`) - rust-lang#153143 (Allow `./x test` to run tests without doc tests and without benchmarks) - rust-lang#153471 (Refactor `ActiveJobGuard`) - rust-lang#153595 (`QueryLatch` cleanups) - rust-lang#153653 (scalable vector: type renames and simple checks) - rust-lang#152302 (fix: don't suggest replacing `env!("CARGO_BIN_NAME")` with itself) - rust-lang#153283 (feat(rustdoc-json): Add optional support for rkyv (de)serialization) - rust-lang#153479 (Add rationale for intentional potential_query_instability allows) - rust-lang#153533 (Fix LegacyKeyValueFormat report from docker build: miscellaneous) - rust-lang#153600 (add test for proc-macros with custom panic payloads) - rust-lang#153643 (Avoid projection-only suggestions for inherent assoc types) - rust-lang#153657 (triagebot: remove myself from some mention groups) - rust-lang#153659 (Mark an unreachable match arm as such)
|
@rust-timer build 69b11eb |
|
Queued 69b11eb with parent 0c68443, future comparison URL. |
View all comments
Motivation
The JSON documents produced by
rustdoc-jsonare big. More often than not, tools need to access a small fraction of that output—e.g. a couple of types from a transitive dependency, or a subset of the fields on a givenrustdoc-json-typestype.Using a binary (de)serialization format and a cache helps to drive down the performance cost of deserialization: you invoke
rustdoc-jsonto get the JSON output you need, re-serialize it using a more perfomant format as target (e.g.bincodeorpostcard) and thus amortize the cost of future queries that hit the persistent cache rather thanrustdoc-json.This is better, but still not great: the deserialization cost for crates like
stdstill shows up prominently in flamegraphs.An Alternative Approach: rkyv
rkyvprovides a different opportunity: you avoid paying the deserialization cost upfront thanks to zero-copy deserialization.You're often able to determine if you need a certain entry from the JSON document using the archived version of that type, thus incurring the full deserialization cost only for the subset of items you actually need (example).
The Change
This PR adds support for
rkyvbehind a feature flag (rkyv_0_8).For most types, it's a straight-forward
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)annotation. For co-recursive types, we need to adjust the generated bounds, using the techniques fromrkyv's JSON example.I have added new round-trip tests to ensure
rkyvworks as expected.r? @aDotInTheVoid