Skip to content

Use GetUninitializedObject in IStructuralReadWrite.Read #2669

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

Open
joshua-spacetime opened this issue Apr 24, 2025 · 2 comments
Open

Use GetUninitializedObject in IStructuralReadWrite.Read #2669

joshua-spacetime opened this issue Apr 24, 2025 · 2 comments
Assignees

Comments

@joshua-spacetime
Copy link
Collaborator

That is, fix this TODO:

// TODO: use `RuntimeHelpers.GetUninitializedObject` as an optimisation here.
// We tried but couldn't do this because BitCraft relies on being able
// to add and initialize custom fields on autogenerated classes.

Currently each row object is instantiated using reflection during deserialization which represents a significant portion of the total cost as the following profile snippet demonstrates.

Image
@kazimuth
Copy link
Contributor

kazimuth commented Apr 25, 2025

I didn't realize new T() compiles to something with reflection, that's nasty. Life without monomorphisation I guess.

@joshua-spacetime
Copy link
Collaborator Author

Note, if the above TODO cannot be resolved, an alternative would be to cache new T() and just copy it for each row decode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants