Skip to content
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

Enable by-line buffering for stderr #33

Open
k-bx opened this issue Apr 27, 2015 · 2 comments
Open

Enable by-line buffering for stderr #33

k-bx opened this issue Apr 27, 2015 · 2 comments

Comments

@k-bx
Copy link
Contributor

k-bx commented Apr 27, 2015

It turned out that GHC by default does "no buffering" for stderr, and for hslogger this might be a huge performance-bottleneck.

Here's an example of a script that confirms performance problems: https://gist.github.com/k-bx/ccf6fd1c73680c8a4345 (please, don't pay any attention to "timeout" thing, initiall I thought the problem lies in concurrent usage of hslogger).

In order to resolve problem, you can either manually put hSetBuffering stderr LineBuffering in your program, or disable logging to stderr at all.

I think that hslogger should do its best in order to not put a person into a situation when logging consumes huge amount of time, and I would propose to somehow determine that user is willing to use logging to stderr and in that case doing hSetBuffering stderr LineBuffering in order to switch buffering to LineBuffering mode.

@jgoerzen
Copy link
Collaborator

I would be open to documenting this. However, I do not think that hslogger changing the behavior of stderr is a desired side-effect. The user could easily enough do that themselves if that's what they want.

@anacrolix
Copy link

I've just run into this problem too. Stumbled on to this issue with some googling. I am getting log messages interleaved character for character when logging to stderr. I'll try hSetBuffering stderr LineBuffering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants