Current heap size and other runtime statistics -- API for accessing in GHC?

Hi cafe, The rtsopts (-s etc) can provide some nice debugging information regarding memory management. And System.Mem.performGC can initiate garbage collection. But are there APIs for querying the current state of the heap? I've googled and come up dry. In this case I'm running benchmarks and for the sake of fair comparison I want to make sure that everything from a previous run is cleaned up before the next run. Thanks, -Ryan

Simon Marlow and I had this conversation not too long ago, and the answer is no. However, this is definitely something that would be useful for a lot of people (GHC developers included!) Cheers, Edward Excerpts from Ryan Newton's message of Sun Apr 10 17:30:50 -0400 2011:
Hi cafe,
The rtsopts (-s etc) can provide some nice debugging information regarding memory management. And System.Mem.performGC can initiate garbage collection. But are there APIs for querying the current state of the heap? I've googled and come up dry.
In this case I'm running benchmarks and for the sake of fair comparison I want to make sure that everything from a previous run is cleaned up before the next run.
Thanks, -Ryan

I'd like a proper FFI binding for getting at Stats.c dynamically. So I
can write programs that determine their own stats about the GC and so
on.
On Sun, Apr 10, 2011 at 2:30 PM, Ryan Newton
Hi cafe, The rtsopts (-s etc) can provide some nice debugging information regarding memory management. And System.Mem.performGC can initiate garbage collection. But are there APIs for querying the current state of the heap? I've googled and come up dry. In this case I'm running benchmarks and for the sake of fair comparison I want to make sure that everything from a previous run is cleaned up before the next run. Thanks, -Ryan
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 11/04/2011 12:52 AM, Don Stewart wrote:
I'd like a proper FFI binding for getting at Stats.c dynamically. So I can write programs that determine their own stats about the GC and so on.
I have often wished that there was a much bigger API for interacting with the RTS. Currently, you can query how many capabilities there are, and you can request a (magor?) GC cycle. And that's *it*. One can imagine a far richer API, with the ability to do things like set and query RTS flags, query the GHC version number and RTS "way", ask how much RAM is allocated to what, request a minor or magor GC, try to release RAM to the OS, pre-allocate RAM from the OS because you're about to use it, find out how many threads are running or how many sparks are queued, and so on. Of course, I doubt anyone is going to implement it anytime soon...
participants (4)
-
Andrew Coppin
-
Don Stewart
-
Edward Z. Yang
-
Ryan Newton