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

Lazy string interpolation in ENSURE #2454

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alexbereznikov
Copy link

String interpolation on hot paths leads to performance degradation. We need these messages only when error happened.
With #2453 applied this gives 3x performance boost.

This partially fixes #2451

@ltetak
Copy link
Contributor

ltetak commented Mar 26, 2024

Good catch. I guess it would be more standard to move the string interpolation deeper as other libraries do it.
public static void ENSURE(bool conditional, string message, params object[] args)

@alexbereznikov
Copy link
Author

@ltetak Sure I thought about that, but profiling says that most of the time was lost in BasePage.ToString() and I'm not quite sure how to avoid calculating it when passing via args

@alexbereznikov
Copy link
Author

@ltetak Actually this .ToString() call is redundant as formatter will call it either way. So it should work in the way you proposed, pushed fixed code, please take a look

@ltetak
Copy link
Contributor

ltetak commented Mar 27, 2024

@alexbereznikov I am not an owner of this repo. But this looks like a great performance improvement without any risks or side effects.
cc: @mbdavid

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

Successfully merging this pull request may close these issues.

[BUG] Performance degradation in v5.0.18
2 participants