You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Switch Project data structures from ImmutableDictionary => Dictionary and lock (#78287)
Solution/Project classes keep several immutable dictionaries for mapping (Document/Project)Id to various data. ImmutableDictionaries are a fine (but slow) data structure when data between versions is to be shared, but none of the values in these ImmutableDictionaries persist between solution/project transformations. In fact, the only operation performed on these dictionaries is GetOrAdd calls. As immutable dictionaries are quite poor performing wrt lookups/adds, I thought I would try out two approaches to see if they showed improvements:
Switch to ConcurrentDictionary (see *** WIP: Switch Project data structures from ImmutableDictionary => ConcurrentDictionary #78285).
Switch to simple Dictionaries guarded by locks (this PR)
I created test insertions for each of these PRs to gather speedometer numbers, particularly during the solution load of the c# editing speedometer test. The measurements below are from GC Heap Allocs and CPU samples for those tests under (Solution/Project).GetDocument calls
ConcurrentDictionary change test insertion: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/631277
Dictionary/lock test insertion: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/631278
*** Baseline ***
Alloc: 120 MB (1.0%)
CPU: 560 ms (0.3%)
*** Concurrent Dictionary ***
Alloc: 59 MB
CPU: 258 ms (0.1%)
*** Dictionary with lock ***
Alloc: 28 MB
CPU: 172 ms (< 0.1%)
So, it looks like the best performing of the bunch is this PR, which uses simple dictionaries and locks, thus why I'm elevating this PR out of draft mode. The ConcurrentDictionary PR is interesting as the code changes are simple and do give a nice perf improvement.
0 commit comments