-
-
Notifications
You must be signed in to change notification settings - Fork 369
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
Log live_bytes and heap_size as reported by GHC.Stats #1508
Conversation
09b0657
to
a705897
Compare
Do either of these values include the bytes allocated in the foreign heap? |
heapStatsInterval :: Int | ||
heapStatsInterval = 60_000_000 -- 60s | ||
|
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 should be a config option
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.
A command line option? I am not sure configuring this is very useful,
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.
60s seems arbitrary. A config or command line option would make the choice available to the user
format m = T.pack (printf "%.2fMB" (fromIntegral @Word64 @Double m / 1e6)) | ||
message = "Live bytes: " <> format live_bytes <> " " <> | ||
"Heap size: " <> format heap_size | ||
logInfo l message |
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.
Is Info the right severity? Telemetry?
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.
I choose Info
so that it would show up in any logs that users posted. I can change it to something else if you think it's appropriate (and would show up in logs somewhere under "normal" usage).
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.
I guess it depends what the purpose of this logging is.
Do you mean allocations due to |
What is the purpose of this logging? If it is to make bug reports then it would be better to show the full RSS or similar, the GHC heap alone is just a fraction of the total memory used by the process |
Do you think that a significant amount of RSS for ghcide is off-heap allocations? I would expect the "heap size" number to be quite close to RSS (and this patch would allow people to check easily). |
Around half and half. |
I just tried loading ghcide into ghcide and then looked at reported
The |
The numbers I see for my test of loading ghcide into ghcide are:
Which makes sense, as there is If I reenable idle GC then I get probably more accurate numbers
Basically, I think these numbers allow you to work out Rss accurately and the Rss makes sense relative to the live bytes. |
Does the space used by |
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.
In any case, there is no reason to not merge this already and it can always be made more accurate later on. Thanks!
At least FastString and ByteString are heap allocated (using newByteArray#/newPinnedByteArray#) |
I didn't test with multiple components but I don't see why it would report incorrect numbers. |
Anyone want to merge this? |
This comment has been minimized.
This comment has been minimized.
A thread is spawned which at a prespecified interval will report the live bytes and heap size at the last major collection. Live bytes corresponds to how much live data a program has and should match closely the value reported during heap profiling. Heap size reports the total amount of memory the RTS is using, which corresponds more closely to OS memory usage. ``` [INFO] Live bytes: 367.45MB Heap size: 676.33MB ``` Closes haskell#1493
463ed1f
to
c460f78
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
As #1493 is still open (so still needed) & people proclaimed PR ready & awaiting merge several times, and my additions to it were simple (just a |
Thanks everybody, especially @mpickering @pepeiborra (& with that sending the additional notice that this statistic is merged). |
A thread is spawned which at a prespecified interval will report the
live bytes and heap size at the last major collection.
Live bytes corresponds to how much live data a program has and should
match closely the value reported during heap profiling.
Heap size reports the total amount of memory the RTS is using, which
corresponds more closely to OS memory usage.
Closes #1493