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

Update the WeakStringCache to keep strong references to smaller strings. #11271

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Erarndt
Copy link

@Erarndt Erarndt commented Jan 13, 2025

Fixes #

Context

The current string cache implementation uses weak GC handles to avoid holding onto references to strings for longer than needed. As a result, the strings are frequently collected and recreated. Additionally, weak references add additional cost to each garbage collection. The proposed implementation would keep only use a weak reference for larger strings since the cost of keeping around smaller strings generally outweighs the cost of recreating them.

Changes Made

Testing

Notes

@SimaTian
Copy link
Member

Hello and thank you for looking into possible performance improvements.
Do you have any benchmarking around the possible performance gain please?
If yes, could you share your data?
How was the 500 char threshold selected? (I think that 500 is a threshold that will capture most of the strings that MSBuild generates)

@JanKrivanek
Copy link
Member

Related to #11160

@Erarndt
Copy link
Author

Erarndt commented Jan 14, 2025

Hello and thank you for looking into possible performance improvements.
Do you have any benchmarking around the possible performance gain please?
If yes, could you share your data?
How was the 500 char threshold selected? (I think that 500 is a threshold that will capture most of the strings that MSBuild generates)

I have lots of various data including traces with PerfView and build times. If you're looking for something specific, I likely have it :). The value was chosen somewhat arbitrability, but I did see a good number of strings that were significantly larger (1000+). There's likely some tuning we could do on the specific value.

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.

3 participants