-
Notifications
You must be signed in to change notification settings - Fork 661
perf: use append instead of Concat in appendLookupLocations #632
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
perf: use append instead of Concat in appendLookupLocations #632
Conversation
This reduces alloc/GC churn as append in theory can expand a slice without having to copy the original. Loosely this appears to massively improve performance inside ResolveModuleName.
@andrewbranch would know better but IIRC there's some hazard in this specific case where the way the initial slice comes in could mean that the slices are shared between two things. We'd need to audit to make sure that the initial slice is a copy/clipped so that these appends are safe. |
Gotcha, I did a check for this before raising and I couldn't see any case where the caller was both consuming and providing the slice into this method, i.e. only one thing ends up holding the slice Also worth noting that we aren't appending to the input here, rather appending the input to the existing value. So even if something does retain the input, we're effectively copying it in this case still anyway |
To make me feel better, can you check to see if you do |
Can do, I strongly suspect it won't retain all the perf improvements tho as by definitions we'd be removing the extra space we're currently appending into |
# 1.0.0 (2025-06-25) ### Bug Fixes * **1196:** extend parameter matching with index fallback when name matching fails ([microsoft#1241](https://github.com/zshannon/typescript-go/issues/1241)) ([8975084](8975084)) * **1250:** fix bigint literal type declaration emit ([microsoft#1258](https://github.com/zshannon/typescript-go/issues/1258)) ([6e03d62](6e03d62)) * **949:** fix unmatched closing tags in JSX with referenced identifiers ([microsoft#1056](https://github.com/zshannon/typescript-go/issues/1056)) ([671b5cb](671b5cb)) * avoid treating await in jsdoc as top-level await ([microsoft#877](https://github.com/zshannon/typescript-go/issues/877)) ([656029e](656029e)) * **docs:** Ensure function documentation appears on hover ([microsoft#739](https://github.com/zshannon/typescript-go/issues/739)) ([b2655e6](b2655e6)) ### Features * **911:** erasableSyntaxOnly not supported ([microsoft#1068](https://github.com/zshannon/typescript-go/issues/1068)) ([ddb1ebb](ddb1ebb)) ### Performance Improvements * use append instead of Concat in appendLookupLocations ([microsoft#632](https://github.com/zshannon/typescript-go/issues/632)) ([026e5f9](026e5f9))
# 1.0.0 (2025-06-25) ### Bug Fixes * **1196:** extend parameter matching with index fallback when name matching fails ([microsoft#1241](https://github.com/zshannon/typescript-go/issues/1241)) ([8975084](8975084)) * **1250:** fix bigint literal type declaration emit ([microsoft#1258](https://github.com/zshannon/typescript-go/issues/1258)) ([6e03d62](6e03d62)) * **949:** fix unmatched closing tags in JSX with referenced identifiers ([microsoft#1056](https://github.com/zshannon/typescript-go/issues/1056)) ([671b5cb](671b5cb)) * avoid treating await in jsdoc as top-level await ([microsoft#877](https://github.com/zshannon/typescript-go/issues/877)) ([656029e](656029e)) * **docs:** Ensure function documentation appears on hover ([microsoft#739](https://github.com/zshannon/typescript-go/issues/739)) ([b2655e6](b2655e6)) ### Features * **911:** erasableSyntaxOnly not supported ([microsoft#1068](https://github.com/zshannon/typescript-go/issues/1068)) ([ddb1ebb](ddb1ebb)) ### Performance Improvements * use append instead of Concat in appendLookupLocations ([microsoft#632](https://github.com/zshannon/typescript-go/issues/632)) ([026e5f9](026e5f9))
This reduces alloc/GC churn as append in theory can expand a slice without having to copy the original. Loosely this appears to massively improve performance inside ResolveModuleName. In one example running the LSP locally it drops initialization time from ~90 seconds to ~20 seconds.
I believe this is still safe given the usage of mutex's, but also my understanding of go threading is not the best, so if this isn't safe lemme know. But it appears to be fine both locally and in the test suite.
Before

After
