-
Notifications
You must be signed in to change notification settings - Fork 153
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
Refactor Symbol Cache #384
Conversation
How hard is it to replace it with something meaningful? |
Well, I removed the part of passing data with JSON completely. |
res | ||
|
||
let initializeCache dir = | ||
let connectionString = sprintf "Data Source=%s/.ionide/symbolCache.db" dir |
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.
if we use /.ionide/obj
, that will be git ignored by default by pratically all .gitignores
, so less noise
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.
Another option is that it's passed as argument to FSAC.
So editors can put that:
- or in their temp directory or custom dir
- or can be in a dir inside %TEMP% generated for the workspace so valid until restart and automatically cleaned up.
do if not dbExists then | ||
let fs = File.Create(dbPath) | ||
fs.Close() | ||
let cmd = "CREATE TABLE Symbols( |
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.
this doesnt work if the schema will be updated later to v2.
for example an older symbolcache exists on file, and that's will be used but schema is v1
@Krzysztof-Cieslak btw travis is red also in master, after bfa7f58 was green before |
@enricosada, Regarding comments on code - I've only refactored code here for performance gain, the comments are relevant but I don't want to address them at the moment - it's just refactoring, I don't want to introduce any changes to the feature |
This is ready to merge. |
What a big chungus. It's always great looking at your first run of perf view :) |
It turns out that sending thousands of symbols serialized to JSON through HTTP is not the best idea I've ever had!
I've started working on some performance analyses, and while I don't have yet lot of experience with it there was one big elephant in the room that was noticeable even for me:
The absurd amount of
Int32
allocations caused by Newtonsoft.Json.GC Heap Alloc Ignore Free:
![image](https://user-images.githubusercontent.com/5427083/58323570-a691b480-7e24-11e9-90c8-021961edf92b.png)
![image](https://user-images.githubusercontent.com/5427083/58323615-ca54fa80-7e24-11e9-8509-e94fcdd3685c.png)
Turns out this all was caused by single function -
SymbolCache.sendSymbols
that caused 56% of allocations, and was causing 12% of CPU usage:GC Heap Alloc Ignore Free:
![image](https://user-images.githubusercontent.com/5427083/58324632-b068e700-7e27-11e9-9acb-c266f6a646c3.png)
CPU Stack:
![image](https://user-images.githubusercontent.com/5427083/58324729-fcb42700-7e27-11e9-9a79-cc0ea8583668.png)
It was also causing ~40% of Large Object allocations:
![image](https://user-images.githubusercontent.com/5427083/58324861-659b9f00-7e28-11e9-98db-3dde0a5757a4.png)
GC Heap Alloc Ignore Free:
After the refactoring main FSAC process inserts symbols to SQLite directly, and only sends notification to the SymbolCache process that the DB was updated and it should be loaded to memory.
After the refactoring
![image](https://user-images.githubusercontent.com/5427083/58325341-af38b980-7e29-11e9-9f0d-6b24ce0eb912.png)
SymbolCache.sendSymbols
causes 5% of CPU usage and 14% of allocations:GC Heap Alloc Ignore Free:
CPU Stack:
![image](https://user-images.githubusercontent.com/5427083/58325172-42bdba80-7e29-11e9-85d7-5e77ceb6d900.png)
I've also observed decrease on Large Object allocations from around 3% to 1% and GCStats are not showing any LOH allocation pauses.
Pre refactoring:
![image](https://user-images.githubusercontent.com/5427083/58325634-a7c5e000-7e2a-11e9-829e-d533d6a8bebc.png)
Post refactoring:
![image](https://user-images.githubusercontent.com/5427083/58325599-8664f400-7e2a-11e9-92c3-cb7826a7c5c9.png)