mirror of
https://github.com/facebook/Haxl.git
synced 2024-10-04 06:07:32 +03:00
Include the number of times a label is entered in the ProfileData
Summary: We have the number of times memoization hit under a label, but not the number of times the label itself is entered. Let us collect this stat as well, which can help us find hot functions and compute memoization hit rate. Reviewed By: karen Differential Revision: D19377120 fbshipit-source-id: 33046301badca5c32df20b06c77c863636562612
This commit is contained in:
parent
fd69fa08f6
commit
65b9ab8595
@ -57,6 +57,7 @@ module Haxl.Core (
|
||||
, ProfileData(..)
|
||||
, emptyProfileData
|
||||
, AllocCount
|
||||
, LabelHitCount
|
||||
, MemoHitCount
|
||||
|
||||
-- ** Tracing flags
|
||||
|
@ -89,10 +89,15 @@ modifyProfileData env label allocs =
|
||||
newEntry =
|
||||
emptyProfileData
|
||||
{ profileAllocs = allocs
|
||||
, profileDeps = HashSet.singleton caller }
|
||||
, profileDeps = HashSet.singleton caller
|
||||
, profileLabelHits = 1
|
||||
}
|
||||
updEntry _ old =
|
||||
old { profileAllocs = profileAllocs old + allocs
|
||||
, profileDeps = HashSet.insert caller (profileDeps old) }
|
||||
old
|
||||
{ profileAllocs = profileAllocs old + allocs
|
||||
, profileDeps = HashSet.insert caller (profileDeps old)
|
||||
, profileLabelHits = profileLabelHits old + 1
|
||||
}
|
||||
-- subtract allocs from caller, so they are not double counted
|
||||
-- we don't know the caller's caller, but it will get set on
|
||||
-- the way back out, so an empty hashset is fine for now
|
||||
|
@ -34,6 +34,7 @@ module Haxl.Core.Stats
|
||||
, ProfileData(..)
|
||||
, emptyProfileData
|
||||
, AllocCount
|
||||
, LabelHitCount
|
||||
, MemoHitCount
|
||||
|
||||
-- * Allocation
|
||||
@ -161,6 +162,7 @@ numFetches (Stats rs) = sum [ fetchBatchSize | FetchStats{..} <- rs ]
|
||||
|
||||
type ProfileLabel = Text
|
||||
type AllocCount = Int64
|
||||
type LabelHitCount = Int64
|
||||
type MemoHitCount = Int64
|
||||
|
||||
newtype Profile = Profile
|
||||
@ -178,10 +180,12 @@ data ProfileData = ProfileData
|
||||
-- ^ labels that this label depends on
|
||||
, profileFetches :: HashMap Text Int
|
||||
-- ^ map from datasource name => fetch count
|
||||
, profileLabelHits :: {-# UNPACK #-} !LabelHitCount
|
||||
-- ^ number of hits at this label
|
||||
, profileMemoHits :: {-# UNPACK #-} !MemoHitCount
|
||||
-- ^ number of hits to memoized computation at this label
|
||||
-- ^ number of hits to memoized computation at this label
|
||||
}
|
||||
deriving Show
|
||||
|
||||
emptyProfileData :: ProfileData
|
||||
emptyProfileData = ProfileData 0 HashSet.empty HashMap.empty 0
|
||||
emptyProfileData = ProfileData 0 HashSet.empty HashMap.empty 0 0
|
||||
|
Loading…
Reference in New Issue
Block a user