Opened 6 years ago

Closed 2 years ago

#5364 closed feature request (fixed)

Access RTS flag values from inside Haskell programs

Reported by: ezyang Owned by: ekmett
Priority: normal Milestone: 7.10.1
Component: Core Libraries Version: 7.3
Keywords: Cc: johan.tibell@…, hvr, core-libraries-committee@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #10022 Differential Rev(s): Phab:D306
Wiki Page:

Description (last modified by ezyang)

Strictly speaking, it is already possible to do this since includes/rts/Flags.h exports RtsFlags, which can be accessed with a mini wrapper function. We should add this wrapper function so we can import it, and then write code which reads out the contents of all the various parameters so that users can introspect this at runtime. Maybe put them in the GHC.RTS module.

Change History (12)

comment:1 Changed 5 years ago by igloo

Milestone: 7.6.1

comment:2 Changed 5 years ago by tibbe

Cc: johan.tibell@… added

comment:3 Changed 4 years ago by igloo

Milestone: 7.6.17.6.2

comment:4 Changed 3 years ago by ezyang

Cc: hvr added
Description: modified (diff)
difficulty: Unknown

comment:5 Changed 3 years ago by thoughtpolice

Milestone: 7.6.27.10.1

Moving to 7.10.1.

comment:6 Changed 2 years ago by thoughtpolice

Component: libraries/baseCore Libraries
Owner: set to ekmett

Moving over to new owning component 'Core Libraries'.

comment:7 Changed 2 years ago by thomie

Cc: core-libraries-committee@… added
Differential Rev(s): Phab:D306

comment:8 Changed 2 years ago by Austin Seipp <austin@…>

In 1617a10aaa75567b776d4a47200ddaa1267771db/ghc:

accessors to RTS flag values -- #5364

Summary: Implementation of #5364. Mostly boilerplate, reading FILE fields is missing.

Test Plan:
- Get some feedback on missing parts. (FILE fields)
- Get some feedback on module name.
- Get some feedback on other things.
- Get code reviewed.
- Make sure test suite is passing. (I haven't run it myself)

Reviewers: hvr, austin, ezyang

Reviewed By: ezyang

Subscribers: ekmett, simonmar, ezyang, carter, thomie

Differential Revision: https://phabricator.haskell.org/D306

GHC Trac Issues: #5364

Conflicts:
	includes/rts/Flags.h

comment:9 Changed 2 years ago by thoughtpolice

Milestone: 7.10.17.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:10 Changed 2 years ago by Herbert Valerio Riedel <hvr@…>

In 40561cd235f07d41904d2604ff7f0c942af4d35e/ghc:

Fix `heapSizeSuggesionAuto` typo (#9934)

This was introduced in 1617a10a (re #5364)

comment:11 Changed 2 years ago by hvr

Milestone: 7.12.17.10.1

btw, I noticed that the API exposed by GHC.RTS.Flags varies depending on unsigned int:

-- | @'nat'@ defined in @rts/Types.h@
type Nat = #{type unsigned int}

data GCFlags = GCFlags
    { statsFile             :: Maybe FilePath
    , giveStats             :: GiveGCStats
    , maxStkSize            :: Nat
    , initialStkSize        :: Nat
    , stkChunkSize          :: Nat
...

Is this really a good idea rather simply using Word which I assume should always be large enough to contain the range of CULong?

Moreover, shouldn't most of those small-fields be !-ed to avoid thunks and unecessary pointer chasing?

comment:12 Changed 2 years ago by thoughtpolice

Resolution: fixed
Status: newclosed

Yes, we should make those cleanups. I've filed another ticket: #10022. However, this ticket is (in general) worth closing.

Note: See TracTickets for help on using tickets.