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

[Performance]: SmallElementLocation optimisation doesn't actually do anything #10028

Closed
drewnoakes opened this issue Apr 18, 2024 · 1 comment
Assignees
Labels
bug performance Performance-Scenario-General This issue affects performance in general.

Comments

@drewnoakes
Copy link
Member

drewnoakes commented Apr 18, 2024

In the construction model, each element stores its location in the source file in an ElementLocation instance.

There are two implementations of this abstract base class: SmallElementLocation and RegularElementLocation, storing line/column data using ushort and int respectively.

The rationale here is that most values are small (< 0xFFF) and so using different storage sizes in different cases can reduce memory footprint.

However, the CLR will align the fields of this class to four-byte boundaries on most architectures for performance reasons. Therefore the optimisation in SmallElementLocation is unlikely to have any effect.

The padding/alignment can be verified here.

@drewnoakes
Copy link
Member Author

My analysis was incorrect and the object layout does in fact work as intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug performance Performance-Scenario-General This issue affects performance in general.
Projects
None yet
Development

No branches or pull requests

1 participant