Skip to content

Unnecessary allocations in UncommonField<T> for bool #10677

@h3xds1nz

Description

@h3xds1nz

Note that I will submit a PR in the coming days for this issue, so its more of an FYI.

Description

#4220 attempted to fix this problem but it completely changed the behaviour and so it was reverted (plus, it won't really fix the problem as the values then get boxed during insertion anyways (and it won't prevent insertion due to the fact that most paths are inserting true and default is false)).

Before it was reverted, in #6528, Stephen added boolean path (it gets compiled only for the bool generic paths) which solves the problem for insertions as well, but during the reversal in #7426 this was made useless once again, because you now box during ReferenceEquals check, so that optimization is pointless.

My repro is for UIA but the same will occur for HiearchicalVirtualization for example (see #4114).

Showcase

Image

Repro

Note: This repro is specifically crafted to highlight an issue like this.

https://github.com/h3xds1nz/UIAPerformancePitfalls

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions