Ticket #5846 (closed feature request: fixed)

Opened 16 months ago

Last modified 11 months ago

Add GHC.Stats.gcStatsEnabled

Reported by: tibbe Owned by:
Priority: normal Milestone: 7.6.1
Component: libraries (other) Version: 7.4.1
Keywords: Cc: ezyang
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

It would be nice if GHC.Stats exported a new, top-level constant, gcStatsEnabled :: Bool, that's set to True if the program was run with RTS -T or equivalent. In addition we could consider throwing an exception if getGCStats was called when gcStatsEnabled = False. This would let programs check if GC stats collection is enabled and still do something reasonable if they're not. This would be useful in the ekg package.

Open question: could the value of +RTS -T change at runtime? If so, perhaps we instead want getGCStatsEnabled :: IO Bool.

Attachments

5846-base.patch Download (1.8 KB) - added by pcapriotti 11 months ago.
5846-rts.patch Download (1.8 KB) - added by pcapriotti 11 months ago.

Change History

Changed 11 months ago by pcapriotti

  • difficulty set to Unknown
  • milestone set to 7.6.1

Changed 11 months ago by pcapriotti

Changed 11 months ago by pcapriotti

Changed 11 months ago by pcapriotti

  • status changed from new to patch

Attached are patches implementing getGCStatsEnabled.

I don't think the value can change at runtime, but I used an IO Bool type anyway, to keep the -XSafe flag on GHC.Stats.

Changed 11 months ago by tibbe

Patch looks good to me.

Changed 11 months ago by pcapriotti

  • status changed from patch to closed
  • resolution set to fixed

Thanks. Pushed:

commit 05cf0016f23c9b1f6d4ef0f820c0fd8f56ff02c1
Author: Paolo Capriotti <p.capriotti@gmail.com>
Date:   Fri Jun 15 17:13:16 2012 +0100

    Add GHC.Stats.getGCStatsEnabled function (#5846)
    
    Add getGCStatsEnabled function which checks whether GC stats have been
    enabled (with `-T`, for example).
    
    Make getGCStats throw an exception if called with GC stats disabled.
Note: See TracTickets for help on using tickets.