quchen / prettyprinter

A modern, extensible and well-documented prettyprinter.
BSD 2-Clause "Simplified" License
293 stars 34 forks source link

renderIO documentation is suspect, performance of renderLazy + hPutStr is better #196

Open vmchale opened 3 years ago

vmchale commented 3 years ago

The renderIO documentation says that it is more efficient, but it seems to be slower when writing to files on Linux.

I recently switched things around in one of my projects to make it faster! https://github.com/vmchale/kempe/commit/59a73c5a8606dd3377b196049e63b44105c33a24

sjakobi commented 3 years ago

Thanks for the report, Vanessa! :)

Which GHC version did you experience this with?

BTW, if performance is very important in your usecase, you could try using layoutCompact instead of layoutPretty.

vmchale commented 3 years ago

GHC 9.0.1!

Thanks, I will!

I might be mistakenly not using hFlush let me see :thinking:

vmchale commented 3 years ago

Hm, I don't think that's hFlush.

I'll look at layoutCompact, thank you!

sjakobi commented 3 years ago

So text is reported to show massive performance regressions with GHC 9.0.1: https://gitlab.haskell.org/ghc/ghc/-/issues/19557

I think we should wait for GHC 9.0.2 and the next text release and then take another look.

quchen commented 3 years ago

In general I’m in favor for phasing out the renderIO etc. functions – there are too many combinations of layouting, rendering, and IO-ing. Typically everyone writes their own combinations anyway, and renderIO is only a very specific use case that clutters the API.