microsoft / microsoft/CsWin32

Perf improvement opportunities

Open
#612 6 comments 0 reactions 0 assignees View on GitHub

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.GetMetadataReader is apparently quite slow because of some in-memory buffer copies. We can pool and recycle the result of this call.
  • TryGetEnumName exhaustively 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.
  • GetMethodsByName spends 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.
  • TryGenerateConstant spends 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.
  • TryGenerateType spends 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.