-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix memory leak bug #4
base: api-0_0_3_6
Are you sure you want to change the base?
Conversation
Should this target the |
our current nixpkgs overlay setup on hs-opentelemetry-* is pretty messy right now. we are not using hs-opentelemetry-* from a single commit and for this package, we were actually using hackage 0.0.3.6 version, not from git source. so I first made this on top of 0.0.3.6. (otherwise, the build failed in other places). So refer to this for showing diff. I will make a direct patch for our build and for the upstream of hs-opentelemetry, I will make a PR again. Thanks. |
I was able to build it on top of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left comments indicating where strictness annotations are not necessary. I have tested these suggestions.
@@ -97,7 +100,7 @@ addAttribute AttributeLimits{..} Attributes{..} k v = case attributeCountLimit o | |||
|
|||
addAttributes :: ToAttribute a => AttributeLimits -> Attributes -> [(Text, a)] -> Attributes | |||
-- TODO, this could be done more efficiently | |||
addAttributes limits = foldl (\attrs' (k, v) -> addAttribute limits attrs' k v) | |||
addAttributes limits = foldl' (\(!attrs') (!k, !v) -> addAttribute limits attrs' k v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bang on attrs'
is redundant because we're using foldl'
:
addAttributes limits = foldl' (\(!attrs') (!k, !v) -> addAttribute limits attrs' k v) | |
addAttributes limits = foldl' (\attrs' (!k, !v) -> addAttribute limits attrs' k v) |
@@ -394,7 +394,7 @@ addAttribute :: (MonadIO m, A.ToAttribute a) | |||
-> a | |||
-- ^ Attribute value | |||
-> m () | |||
addAttribute (Span s) k v = liftIO $ modifyIORef s $ \i -> i | |||
addAttribute (Span s) k v = liftIO $ modifyIORef' s $ \i -> i `seq` i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seq
is redundant because i
comes from the IORef
, and now that we use modifyIORef'
, it is already evaluated.
addAttribute (Span s) k v = liftIO $ modifyIORef' s $ \i -> i `seq` i | |
addAttribute (Span s) k v = liftIO $ modifyIORef' s $ \i -> i |
The other seq
in this file are also redundant.
a few strictness annotation and using proper strict functions makes memory leak go away.