-
-
Notifications
You must be signed in to change notification settings - Fork 108
perf: use ValueStringBuilder to avoid allocations
#4231
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
base: main
Are you sure you want to change the base?
Conversation
e89aa27 to
d79a9a7
Compare
d79a9a7 to
f67a0e1
Compare
f67a0e1 to
d0e9c4d
Compare
SummaryOptimizes TestIdentifierService by replacing StringBuilder and ArrayPool with ValueStringBuilder and ValueListBuilder to reduce heap allocations during test ID generation. Critical IssuesNone found ✅ Suggestions
Verdict✅ APPROVE - No critical issues This is an excellent performance optimization that follows TUnit's Rule 4 (Performance First). The implementation:
The benchmarks show significant improvement (124 B → 56 B allocated). Great work! |
|
This seems to have broken execution for a bunch of tests. I think using a custom collection is quite risky too. Maybe we should leave this one. |
What are the errors? I wouldn't be surprised if I messed up the logic without any tests: 😊
Fair enough, I had a lot of plans to use these but I can adapt. For what it's worth the collections are both internally used by Microsoft in the .Net runtime and IMO are easier to use than |
|
How come they don't add it into the core library? I haven't investigated properly, but it's expected things like 84 tests in a run and only getting 13. Click on the Ubuntu pipeline failures on the pr checks |
d0e9c4d to
1fd2ced
Compare
|
The failed test are mostly
There is a proposal for this but it's blocked until they add a safety tool. They are worried that people will accidentally misuse it by; copying the |
Uses
ValueListBuilderandValueStringBuilderto drastically reduce allocations inTestIdentifierServiceValueListBuilderhas a lot of potential in other areas ofTUnit; I see a lot of temporary Lists in use.typeSbcould be aVLSbut it's used so infrequently I don't see any point - Happy to change this.VLSas it may see some use if someone uses generic tests.stringallocations andArrayPoolusageBef ore
After