hp2any-core 0.9.0 → 0.10.0
raw patch · 4 files changed
+38/−8 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Profiling.Heap.Process: processToProfile :: FilePath -> Maybe FilePath -> String -> [ProfParam] -> CreateProcess
+ Profiling.Heap.Process: processToProfile :: FilePath -> Maybe FilePath -> [String] -> [ProfParam] -> CreateProcess
- Profiling.Heap.Types: ccName :: (ProfileQuery p) => p -> Int -> CostCentreName
+ Profiling.Heap.Types: ccName :: ProfileQuery p => p -> Int -> CostCentreName
- Profiling.Heap.Types: ccNames :: (ProfileQuery p) => p -> IntMap CostCentreName
+ Profiling.Heap.Types: ccNames :: ProfileQuery p => p -> IntMap CostCentreName
- Profiling.Heap.Types: date :: (ProfileQuery p) => p -> String
+ Profiling.Heap.Types: date :: ProfileQuery p => p -> String
- Profiling.Heap.Types: integral :: (ProfileQuery p) => p -> ProfileSample
+ Profiling.Heap.Types: integral :: ProfileQuery p => p -> ProfileSample
- Profiling.Heap.Types: integralIvl :: (ProfileQuery p) => p -> Time -> Time -> ProfileSample
+ Profiling.Heap.Types: integralIvl :: ProfileQuery p => p -> Time -> Time -> ProfileSample
- Profiling.Heap.Types: job :: (ProfileQuery p) => p -> String
+ Profiling.Heap.Types: job :: ProfileQuery p => p -> String
- Profiling.Heap.Types: maxCost :: (ProfileQuery p) => p -> Cost
+ Profiling.Heap.Types: maxCost :: ProfileQuery p => p -> Cost
- Profiling.Heap.Types: maxCostIvl :: (ProfileQuery p) => p -> Time -> Time -> Cost
+ Profiling.Heap.Types: maxCostIvl :: ProfileQuery p => p -> Time -> Time -> Cost
- Profiling.Heap.Types: maxCostTotal :: (ProfileQuery p) => p -> Cost
+ Profiling.Heap.Types: maxCostTotal :: ProfileQuery p => p -> Cost
- Profiling.Heap.Types: maxCostTotalIvl :: (ProfileQuery p) => p -> Time -> Time -> Cost
+ Profiling.Heap.Types: maxCostTotalIvl :: ProfileQuery p => p -> Time -> Time -> Cost
- Profiling.Heap.Types: maxTime :: (ProfileQuery p) => p -> Time
+ Profiling.Heap.Types: maxTime :: ProfileQuery p => p -> Time
- Profiling.Heap.Types: minTime :: (ProfileQuery p) => p -> Time
+ Profiling.Heap.Types: minTime :: ProfileQuery p => p -> Time
- Profiling.Heap.Types: samples :: (ProfileQuery p) => p -> [(Time, ProfileSample)]
+ Profiling.Heap.Types: samples :: ProfileQuery p => p -> [(Time, ProfileSample)]
- Profiling.Heap.Types: samplesIvl :: (ProfileQuery p) => p -> Time -> Time -> [(Time, ProfileSample)]
+ Profiling.Heap.Types: samplesIvl :: ProfileQuery p => p -> Time -> Time -> [(Time, ProfileSample)]
Files
- CHANGES +5/−0
- Profiling/Heap/Process.hs +3/−4
- Profiling/Heap/Read.hs +28/−3
- hp2any-core.cabal +2/−1
CHANGES view
@@ -1,3 +1,8 @@+0.10.0 - 090812+* changed processToProfile to accept parameters as a list of strings+* added some preliminary Win32 code that still doesn't work due to+ sharing violations+ 0.9.0 - 090810 * switched to Int64 for representing costs * added a Maybe layer to readProfile as well
Profiling/Heap/Process.hs view
@@ -101,10 +101,9 @@ {-| A helper function to create a 'CreateProcess' structure. -} processToProfile :: FilePath -- ^ The executable to profile (relative paths start from the working directory). -> Maybe FilePath -- ^ An optional working directory (inherited from the parent if not given).- -> String -- ^ The list of parameters to pass to the program.+ -> [String] -- ^ The list of parameters to pass to the program. -> [ProfParam] -- ^ Profiling parameters. -> CreateProcess -- ^ The resulting structure.-processToProfile exec dir params profParams = (shell cmd) { cwd = dir }+processToProfile exec dir params profParams = (proc exec allParams) { cwd = dir } where -- Note: this doesn't handle --RTS in the param string!- cmd = exec ++ ' ' : params ++- (if null profParams then "" else " +RTS " ++ show profParams)+ allParams = params ++ (if null profParams then [] else "+RTS" : map show profParams)
Profiling/Heap/Read.hs view
@@ -33,9 +33,15 @@ import System.IO import System.Process +{- Win32 code+import Foreign.ForeignPtr+import System.Win32.File+-}+ -- Data structures import Data.ByteString.Char8 (ByteString) import qualified Data.ByteString.Char8 as S+import Data.ByteString.Internal as SI import Data.List import Data.Maybe import qualified Data.IntMap as IM@@ -184,17 +190,27 @@ profileCallback :: ProfilingCommand -> ProfileSink -> IO (Maybe (ProfilingStop,ProfilingInfo)) profileCallback (Local prog) sink = do dir <- getCurrentDirectory- let hpPath = fromMaybe dir (cwd prog) ++- '/' : (takeFileName . execPath . cmdspec) prog ++ ".hp"- -- Yes, this is extremely naive, but it will do for the time being...+ let -- Yes, this is extremely naive, but it will do for the time+ -- being... Note that processToProfile creates a RawCommand, so+ -- using it should be safe. execPath (ShellCommand cmd) = takeWhile (/=' ') cmd execPath (RawCommand path _) = path + -- The .hp file appears in the working directory of the process, and+ -- shares the name of the executable.+ hpPath <- canonicalizePath $ fromMaybe dir (cwd prog) +++ '/' : (takeFileName . execPath . cmdspec) prog ++ ".hp"+ -- We have to delete the .hp file and wait for the process to create it. catch (removeFile hpPath) (const (return ())) (_,_,_,phdl) <- createProcess prog + -- Unfortunately this doesn't seem to work in Windows due to file+ -- locking. Must use Win32 API to open file for shared reading. maybeHpFile <- tryRepeatedly (openFile hpPath ReadMode) 50 10000+{- Win32 code+ maybeHpFile <- tryRepeatedly (createFile hpPath gENERIC_READ 0 fILE_SHARE_READ Nothing oPEN_EXISTING fILE_ATTRIBUTE_NORMAL Nothing) 50 10000+-} case maybeHpFile of Nothing -> return Nothing@@ -242,6 +258,15 @@ else do newChars <- S.hGetNonBlocking hpFile 0x10000 pass (S.append buf newChars) idmap smp+{- Win32 code+ rawBuf <- mallocByteString 0x10000+ bytesRead <- fromIntegral <$> win32_ReadFile hpFile (unsafeForeignPtrToPtr rawBuf) 0xffff Nothing+ if bytesRead == 0 then do+ threadDelay 100000+ pass buf idmap smp+ else do+ pass (S.append buf (fromForeignPtr rawBuf 0 bytesRead)) idmap smp+-} -- The other process ended, let's notify the callback. else sink SinkStop
hp2any-core.cabal view
@@ -1,5 +1,5 @@ Name: hp2any-core-Version: 0.9.0+Version: 0.10.0 Cabal-Version: >= 1.2 Synopsis: Heap profiling helper library Category: profiling, development, utils@@ -13,6 +13,7 @@ Author: Patai Gergely Maintainer: Patai Gergely (patai@iit.bme.hu) Copyright: (c) 2009, Patai Gergely+Homepage: http://www.haskell.org/haskellwiki/Hp2any License: BSD3 License-File: LICENSE Stability: experimental