Merged
Conversation
d0bbcc1 to
6d701be
Compare
EdwardCooke
requested changes
May 14, 2025
This cuts about 20% of parsing time and probably more in final object graph size, depending on input data of course. In terms of the LoadLarge benchmark: | Method | Mean | Error | StdDev | Gen0 | Gen1 | Gen2 | Allocated | |-----------------:|---------:|--------:|---------:|----------:|----------:|----------:|----------:| | LoadLarge before | 136.9 ms | 3.11 ms | 9.03 ms | 7500.0000 | 3500.0000 | 1500.0000 | 39.65 MB | | LoadLarge after | 114.4 ms | 3.70 ms | 10.67 ms | 6000.0000 | 2000.0000 | 1000.0000 | 39.65 MB | This is just simple string.Intern calls. It's not that much, but it affects a startup time I care about. The change could negatively affect the intern pool if random keys are in the input.
Author
|
I incorporated your comments. But then I revisited my thinking about interning, performance and security. Real programs will have the keys they care about interned already, meaning we should prefer soft interning (IsInterned) to avoid loading the intern pool with crap. But this will be harder to benchmark. I think it boils down to security. If you want YamlDotNet to be resilient to hostile input, I'm happy to switch to IsInterned. |
EdwardCooke
approved these changes
Apr 9, 2026
This was referenced Apr 9, 2026
This was referenced Apr 10, 2026
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.
This cuts about 20% of parsing cost and probably more in final object graph size, depending on input data.
In terms of the LoadLarge benchmark:
This is just a simple string.Intern call. It might make sense to emplyor pass a pool, like a XmlNameTable does with XML, to save on scalar objects not just strings.