Perf improvement opportunities
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- C#
- Stars
- 2.5k
- Forks
- 124
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 9
Description
As a continuation of ongoing perf work, this issue tracks perf improvement opportunities.
- Calling
PEReaderExtensions.GetMetadataReaderis apparently quite slow because of some in-memory buffer copies. We can pool and recycle the result of this call. -
TryGetEnumNameexhaustively searches all enum values in the metadata on every call. On subsequent generations, we should be able to reuse the result of this search rather than repeating it. -
GetMethodsByNamespends a lot of time concatenating strings and in 3 dictionary lookups per namespace in the search. We may be able to consolidate this to just 1 dictionary lookup with no string concatenation. -
TryGenerateConstantspends a lot of time in direct dictionary lookups (one lookup per namespace searched). We might be able to get this down to just one lookup. -
TryGenerateTypespends a lot of time in direct dictionary lookups (one lookup per namespace searched). We might be able to get this down to just one lookup. -
SyntaxNode.GetText, which renders the syntax tree to a SourceText, takes a significant amount of time (as of course does the production of the syntax tree. If we could cache this and safely determine when we can reuse it, that would be supreme.
Some of these items come from this table.
See also #244 for prior work in this area.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the unchecked opportunities around GetMethodsByName, TryGenerateConstant, TryGenerateType, and SyntaxNode.GetText, using the linked discussion and prior work in #244 for context. Determine which optimization is independently actionable and measure its effect; done means the selected lookup or caching improvement is implemented and its performance benefit is verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- performance, tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100