Does ghc-gc-tune 0.2.1 work with ghc 7.4.1?

2019-06-25 01:23发布

问题:

Does ghc-gc-tune 0.2.1 work with ghc 7.4.1? It seems ghc-gc-tune has not been updated for quite a while and may only work with ghc 6.x? I cannot find any reliable information on this.

I get the following error:

ghc-gc-tune: Can't parse GC stats: " ,(\"num_GCs\", \"320602\")\n ,(\"average_bytes_used\", \"105444\")\n ,(\"max_bytes_used\", \"131296\")\n ,(\"num_byte_usage_samples\", \"1677\")\n ,(\"peak_megabytes_allocated\", \"2\")\n ,(\"init_cpu_seconds\", \"0.00\")\n ,(\"init_wall_seconds\", \"0.00\")\n ,(\"mutator_cpu_seconds\", \"6.24\")\n ,(\"mutator_wall_seconds\", \"6.23\")\n ,(\"GC_cpu_seconds\", \"3.57\")\n ,(\"GC_wall_seconds\", \"3.58\")\n ]\n"

回答1:

I have updated the package to work with the GHC 7 series.

Here's the result from a question on the -cafe



回答2:

Line 485 of ghc-gc-tune.hs [1] reads

Right str     -> return $! Just $! parse (unlines . drop 1 . lines $ str)

Which seems to be trimming off the start of your GC infodump, which is then not valid Haskell list syntax - three options in easy→hard order:

  1. make your code print a single newline to stderr when it starts (quick hack)

    main = hPutStrLn stderr "" >> do ...   -- untested...
    
  2. patch ghc-gc-tune.hs to stop it dropping 1 line of stderr

    Right str     -> return $! Just $! parse str   -- untested...
    
  3. patch ghc-gc-tune.hs to try the current way, then without dropping 1 line, picking the one that works most successfully

    -- code left as an exercise
    -- bonus points if it's submitted upstream as a patch
    

Possibly earlier versions of GHC output an additional header on stderr, try something like:

./ghc-compiled-test-program +RTS -t --machine-readable -RTS

to inspect the output.

[1] http://code.haskell.org/~dons/code/ghc-gc-tune/ghc-gc-tune.hs