feat: Allow (de)serialization of PackageGraph#583
feat: Allow (de)serialization of PackageGraph#583LukeMathWalker wants to merge 1 commit intoguppy-rs:mainfrom
PackageGraph#583Conversation
7bf6d29 to
546280c
Compare
546280c to
ab07c40
Compare
|
Thanks for doing this. The core issue with this approach is that the internals are completely unstable and serde would effectively stabilize the internal representation. (This is why the best practice is to have two sets of types, one for serialization and one for internal representation. Today, There is also the concern that deserializers will bypass constructor-enforced invariants unless coded and tested to not do that. If we decide to do this, I'll want to ask you to make a table of every type involved, along with whether the type has constructor-enforced invariants, and if so how the deserializer also enforces these invariants.
See https://docs.rs/target-spec/latest/target_spec/summaries/index.html for serializable representations. Before we do this, could you provide some performance numbers? An option here is we speed up the deserialization and parsing process -- if something shows up in a profile. |
|
Another option to speed up your test suite is that your cached fixture uses CBOR or some other more efficient format, and then you deserialize that CBOR into a |
Computing a
PackageGraphfrom the "raw" output ofcargo metadatacan be rather expensive.When I profiled
pavexUI test suite, I found out that about ~15% of the overall CPU time was going into buildingPackageGraphs, since each test ends up re-building the same graph over and over again starting from a cachedmetadata.jsonfile.So, I wondered, why don't I cache
PackageGraphdirectly? And that's how this PR came to be 😁It adds two new optional features:
serde1to theguppycrateserde1to thetarget-speccrateAll
serdeimplementations are derived, with a few notable exceptions:TargetSpecExpressionsinceExpression, fromcfg_expr, doesn't implementserde's traitsbuild_targets, inPackageMetadataImpl, is serialized as aVecof pairs in order to make its representation JSON-compatible