#4913: Make event tracing conditional on an RTS flag only
---------------------------------+------------------------------------------
    Reporter:  tibbe             |       Owner:                
        Type:  feature request   |      Status:  new           
    Priority:  normal            |   Component:  Runtime System
     Version:  7.0.1             |    Keywords:                
    Testcase:                    |   Blockedby:                
          Os:  Unknown/Multiple  |    Blocking:                
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown  
---------------------------------+------------------------------------------
 The current event tracing mechanism is enabled at link time by linking in
 one of two different versions of a C function, one being a no-op function.
 We could allow users to enable/disable tracing using a RTS flag instead,
 making event logging more convenient to use. At the same time we would
 introduce tracing levels.

 Design:

 Add a static memory location where the current tracing level is stored:

 {{{
 uint tracelevel = 0;
 }}}

 Modify `GHC.Exts.traceEvent` to read

 {{{
 foreign import ccall unsafe "&tracelevel" :: Ptr Word

 traceEvent :: String -> IO ()
 traceEvent msg =
   if unsafePerformIO (peek tracelevel) > 0
   then do
     withCString msg $ \(Ptr p) -> IO $ \s ->
       case traceEvent# p s of s' -> (# s', () #)
   else return ()
 }}}

 and (optionally) add some more functions that log at different trace
 levels.

 This should be no slower than the current system. With inlining this
 should result in a load and a branch at the call site. The load should be
 cheap as the value is likely to be in cache (as it never changes). The
 branch should be easy to predict as it's always the same. With some
 cooperation from the code generator we could make sure that the branch is
 always cheap.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4913>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to