Skip to content
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

MiniYaml performance #20956

Merged
merged 5 commits into from
Jul 17, 2023
Merged

MiniYaml performance #20956

merged 5 commits into from
Jul 17, 2023

Conversation

RoosterDragon
Copy link
Member

A collection of performance improvements to MiniYaml, see individual commits for details.

When loading the RA mod, provides a modest improvement by reducing time spent in MiniYaml.FromLines from 2.8% to 2.4%.

@RoosterDragon RoosterDragon force-pushed the mini-yaml-perf branch 6 times, most recently from 3d30930 to 05e2b8a Compare July 9, 2023 12:35
OpenRA.Game/MiniYaml.cs Outdated Show resolved Hide resolved
OpenRA.Game/MiniYaml.cs Outdated Show resolved Hide resolved
OpenRA.Game/MiniYaml.cs Outdated Show resolved Hide resolved
Use an ImmutableDictionary to avoid having to clone the inheritance tree in ResolveInherits. This avoids a lot of dictionary clones.
Moving the key duplication check allows a redundant check on top-level nodes to be avoided. Add tests to ensure key checks are functioning as expected.
- Track plain keys in a set, to avoid quadratic searches for plain node keys.
- Avoid the Concat iterator by looping twice instead.
- Seal the classes, and make SourceLocation a readonly struct.
- In ToDictionary, use TryAdd to avoid a try-catch.
- In Merge, use ToList to ensure sources is only enumerated once.
Use CollectionsMarshal to hold a ref to the dictionary entry. When the value needs to be added this allows us to set the value directly into it without having to locate the entry a second time.
Copy link
Member

@PunkPun PunkPun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Mailaender Mailaender merged commit 4a02e6c into OpenRA:bleed Jul 17, 2023
3 checks passed
@Mailaender
Copy link
Member

Changelog

@RoosterDragon RoosterDragon deleted the mini-yaml-perf branch July 17, 2023 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants