-
Notifications
You must be signed in to change notification settings - Fork 2
Lighterweight Platform.silentHandler
#143
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
Conversation
I kept the IO in silentHandler to avoid breaking the public API
| -- | Helper that creates a handler that does nothing. This is intended to power | ||
| -- basically @Platform.silentHandler@ and nothing else. We provide this to make | ||
| -- @Platform.silentHandler@ as efficient as possible, skipping all side effects. |
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.
It would be nice to mention memory leaks specifically.
Engineers often disagree on the importance of efficiency, whether certain special cases are justified, etc.
But a memory leak is pretty objective. And if someone changes this code, they need to watch out for that.
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.
Ah, I didn't mention memory leaks because I'm not really sure the leaks are caused by mkHandler. We use mkHandler all the time with other LogHandler instances. What's special about silentHandler? Remember we didn't see leakage in high-throughput apps like HQE before #134? Every request in HQE uses mkHandler.
I think it might be more of an issue of how the handler is being used, than the handler itself.
There's this old article by Edsko de Vries on Conduit and space leaks, which I don't really follow, that reinforces the suspicious there's something about our usage that makes this leak. It seems it's not exactly what Edsko describes tho, because -fno-full-laziness didn't help.
This is also why I was more keen on removing the unused silentHandler logger in our Amazonka wrapper, than fixing it to actually log things to the request's tracing span. If I knew what's really causing the leak and how to fix it, I'd rather have logs.
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.
Although I could leave a word of warning wrt this whole situation. Someone might be grateful.
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.
Yeah exactly 👍
brian-carroll
left a comment
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.
Perfect, thanks!
While digging for space leaks in Nri's Amazonka wrapper, I noticed a bunch of
TracingSpanandTracingSpanDetailsbuilding up where aPlatform.silentHandlerwas being used.Digging into it, I noticed
silentHandlerusesmkHandler, which creates lots ofIORefswhich, insilentHandler's case, were never useful.I made an internal
nullHandlerfunction specifically for the publicsilentHandlerthat does no IO.I still kept
silentHandler : IO LogHandler, even tho I could have made it pure, to keep it a non-breaking change, because I was lazy.