fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

isOpenStatementUsed uses a lot of CPU and memory

Open cartermp opened this issue 5 years ago • 0 comments

I collected a trace after about an hour of working in VisualFSharp.sln when memory was pretty high. I found that the isOpenStatementUsed function is pretty expensive relative to other things.

10.8% of all allocations in the sample (533MB):

image

And 6.3% of total CPU time:

image

This is because the routine does a very expensive list operation where it scans a document's symbols to check if a given open statement is responsible for those symbols (i.e., if the open statement can be removed or not).

This isn't really a big deal with small files, but for large ones (like in the compiler codebase), it bubbles up to the top like this.

Unfortunately, there doesn't seem to be an easy win here. Making this better will likely mean rewriting how we determine if an open declaration is in use.

cartermp avatar May 18 '20 17:05 cartermp