-
Notifications
You must be signed in to change notification settings - Fork 715
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
HistoryDictionary: Replace manually sorted list with SortedDictionary #298
Conversation
@ilabutin, |
Codecov Report
@@ Coverage Diff @@
## master #298 +/- ##
==========================================
+ Coverage 24.35% 24.35% +<.01%
==========================================
Files 199 199
Lines 112479 112483 +4
Branches 11228 11229 +1
==========================================
+ Hits 27397 27399 +2
- Misses 85055 85057 +2
Partials 27 27
Continue to review full report at Codecov.
|
Thanks for looking into this. Changing the underlying data structure of HistoryDictionary is a big enough change that I need to think about it first. The original idea is of a history dictionary is that a particular ID would have few changes over time (it is a Dictionary first). I think this is true for most uses, but breaks down for OS handles that are heavily reused (which seems to happen more now that it did before). Thus there are options to weigh here. It will probably take a couple of days for me to get time to do this, but I will have a response for you by next Monday. |
I had a thought that maybe more clever approach is necessary. If number of entries for given ID is less than, e.g. 5 or 10, then keep them in simple list like it is now. But if number of entries per ID grows then switch to more heavy data structure like SortedDictionary or even something custom. |
Yes, that is one of the options. The fact that there are very different ways of fixing the problem is why I want to think about it a bit before committing. |
Some people on a few VS teams have observed performance issues related to HistoryDictionary as well. There are two things delaying us (the group I referred to) from evaluating this change in that context:
Vance (@vancem) is outside/above this group and has the most knowledge of PerfView scenarios, so he may beat us in getting this change verified. |
I have more input now which may affect the decision of what solution to use. I was thinking that it was related to running a trace with File I/O enabled, but after more careful trace analysis it turned out that it happens for See the PerfView view attached with the hot callstack. I've ran a debug session again with some quickly crafted tracing and indeed I got information that for Most constributing type names are: So, in fact it is not heavy File I/O, it's weird implementation of UI that caused that amount of data to be pushed to Given the fact that at the end we get I can prepare modified pull request with this simple fix and measure how performance is changed in my scenario. PS PPS |
I have finally reverted my Now conversion takes even less - 15 seconds as opposed to 23 seconds with I hope this change is less massive. |
entry = firstEntry.skipAhead; | ||
|
||
HistoryValue last = null; | ||
for (; ; ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 while (true)
is standard for C#. Relevant because different versions of the C# formatter will do different things with for (;;)
, but all of them handle while (true)
consistently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest version does not have this change (I just kept the original code). Should I change it to while (true)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, no. Only if you were changing already.
ID. The newest value wins.
da91db8
to
008773d
Compare
Squashed all commits into one to keep the simplest change only. |
This looks fine (very safe), I will merge it when checks finish. |
HistoryDictionary: Replace manually sorted list with SortedDictionary
This is the attempt to fix issue #297.
I made an attempt to replace manually sorted list which spends a lot of time in linear search inside
Add
with tree-basedSortedDictionary
.After the fix the same file is opened within half a minute as opposed to 4 minutes in the original case:
I didn't experience any issues using PerfView with these changes for a few weeks.
The only 'business logic' change I made is that only single entry is stored for any given timestamp as opposed to the old version. But the lookup algorithm from the old version would have always found the latest added entry and not others, so I made a conclusion that my code should work as well.
If more performance comparison are required - let me know about particular scenarios to test.