-
Notifications
You must be signed in to change notification settings - Fork 789
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
CheckFormatStrings.parseFormatStringInternal appears to split source files many times over causing LOH allocations #5922
Comments
mmm that's interesting. I just looked briefly at that file/function and there is no direct invoction of Split nor Replace. Do you have more details about that stack trace? |
@forki look at the code in branch dev15.9 https://github.com/Microsoft/visualfsharp/blob/dev15.9/src/fsharp/CheckFormatStrings.fs |
@AviAvni ? so you are saying it's already fixed? or what? |
Possibly in #5121 - but that was 5 months ago, as to why that hasn't made it in 15.9... |
@forki not really the code moved to somewhere else in #5121
I'll send PR soon |
@forki when checking the difference with my code
you can see the result that no gc on really big strings the file is 28MB
|
iz's still creating a full copy. Do we really need that? |
What full copy? |
a full copy of the source file in memory. |
OK I debugged it. I only able to reproduce calling to this code when visual studio F# tools(so able to do it only from the dev15.9 branch) |
I dug into the trace a little more, this trace is almost entirely caused by Gen2 collections, caused by the above two LOH allocations. I filed a couple of internal bugs to track the other LOH allocations, but they are not the central cause. I closed the above linked developer community bug in lieu of this one. |
@AviAvni your proposed change is almost certainly already a big improvement. So please send that PR. But my feeling here is that we can do even more. |
@forki PR sent |
When #5943 is merged we should do another comparison. @blumu if you subscript to the F# nightly feed then you can see if the changes make a difference. We should still measure this a bit more though. |
Yep, we've got it and we're currently validating another fix. We can do that with this, too. |
@cartermp I've subscribed to F# nightly. Latest release is from Monday 19th before Avi's PR was merged. I'll let you know how it goes once I get the version with the fix. |
@davkean @cartermp @TIHan I was able to repro typing slow down using nightly build of F# compiler on VS 15.9.3. This time, VS did not yet reach the state where it hangs completely, nor did it crash yet. The ETL trace seems to reveal many Gen2 garbage collections, but I'll let the expert take a look. I will share the trace privately. |
Thanks, send it on and we'll take a look. |
@davkean Trace shared privately. (My VS session is now hanging pretty badly and is unusable, I have to kill it before it dies on its own.) |
Am I reading that right? Only 700MB managed heap? We must have a native leak somewhere. I'm downloading trace now. |
@davkean you are reading the plot correctly. Most of it is private data (in yellow). The trace, though, seems to indicate GC issues. (VS has crashed on its own btw.) Here is the GC Rollup By Generation:
|
Yeah but the trace shows the peak GC heap size was 2.6 GB. |
Given the VM reserved for image loads, etc, that is pretty high. Also, could some of the native VM be the memory mapped files for metadata reading? |
Looking at the GC stats trace (unfortunately, the trace is missing allocation data), the GC heap hovers from about 2.1 -> 2.6 GB, not sure how that maps to that VMMap above. Which name/color are you referring for the native VM? |
Sorry, I was just thinking without really looking closely at the VM Map. It doesn't look like Memory mapped files are a huge problem, as they are around 135MB. My point however was that a 2.6GB Managed heap when added to the 750MB of images above is really quite a lot of address space. Agreed that that doesn't seem to map to the VMMap snapshot above though, unless "Private" is somehow part of the managed memory? Maybe the fact that LOH allocations go directly to VirtualAlloc means that VMMap shows them as Private? |
750MB of images seems a lot but I don't have a reference point. I'm thinking the same thing on the GC heap. |
It is a lot, but it's in line with my expectations for VS unfortunately. |
Just for summary of the thread, the trace was missing allocation data so it didn't give insight into the issue. GC time was pretty much all CPU, with a splattering of other stacks. |
Will close this as #5940 does remove the source file allocations from this function. |
Just wanted to mention that I grabbed a trace from a customer report today where this was causing ~130 MB to be allocated on the LOH. Thanks for making this better @AviAvni 🙂 |
@cartermp any time just ping me if I didn't noticed opportunity to help |
Trace: https://developercommunity.visualstudio.com/content/problem/379694/another-repro-trace-for-github-bug-4718.html
Trace: https://developercommunity.visualstudio.com/content/problem/245786/slow-f-editing-experience-up-to-a-minute-until-typ.html
GC Rollup By Generation
In the above trace, we noticed that we had a tonne of Gen2 collections due to LOH allocations. The first one we noticed that parseFormatStringInternal splits (what appears to be) the source file many times over. For large source files these all end up on the LOH heap:
The text was updated successfully, but these errors were encountered: