perf(json5): Remove use of serde(untagged)#677
Merged
epage merged 1 commit intorust-cli:mainfrom Aug 12, 2025
Merged
Conversation
Pull Request Test Coverage Report for Build 16917008830Details
💛 - Coveralls |
dtolnay
reviewed
Aug 14, 2025
Comment on lines
+29
to
+30
| .seq(|value| value.deserialize().map(Val::Array)) | ||
| .map(|value| value.deserialize().map(Val::Object)) |
There was a problem hiding this comment.
Since this PR is partially motivated by performance, it is worth knowing about dtolnay/erased-serde#61 (which is used by serde-untagged). For very deeply nested config you would see O(n²) performance in the new implementation compared to O(n) in the previous one. Ultimately the best performance would be from a more verbose impl that resembles https://github.com/serde-rs/json/blob/v1.0.142/src/value/de.rs#L22, which completely eliminates the quadratic factor and also reduces linear factor from heap allocations inside erased-serde and constant factor from heap allocations inside UntaggedEnumVisitor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prep for #472
serde(untagged)translates to anif/else ifladder that ends up being pretty expensive, including the error generation for each branch that gets skipped. This switches us to dispatch on type instead, speeding things up.This is also prep for speeding up builds by removing the need for
serde_derive. Onceserde_coreis published, we can depend on that and not wait forsyn,quote, etc.