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

Is it possible to cut on expensive computations when the layout is unbounded? #215

Open
Ptival opened this issue Nov 5, 2021 · 3 comments

Comments

@Ptival
Copy link

Ptival commented Nov 5, 2021

Hello,

I have a very large document that, when printed, takes about 30 seconds if I define commas = fillSep . punctuate commas, but only takes 3 seconds if I define it as commas = hsep . puncuate commas.

Now this discrepancy is possibly acceptable, given fillSep ought to do more work in general. But even when setting the layout to Unbounded, we seem to pay the hefty price of fillSep, even though, unless I'm mistaken, we get the same output that hsep would have given.

This can be annoying if a project provides a fillSep-based printer, but lets the layout to its clients, who then pay the layout price even if they don't really need to.

I may try to give a minimized example later, but my actual project has 30MB input files and a large code base so it's not the ideal setting to minimize.

Also note that the same problem happens with the pretty package.

@sjakobi
Copy link
Collaborator

sjakobi commented Nov 11, 2021

Hi @Ptival!

It does sound like prettyprinter should be able to do better here.

A reproducer would be very helpful though.

It would also be useful if you could check whether there's a regression involved. The perf regression that led to #205 was introduced in v1.7.0. Other potentially buggy layout changes were introduced since v1.5.0.

@Ptival
Copy link
Author

Ptival commented Nov 11, 2021

Tested on 1.6.2 and seems to be the same.

I will try and see if a regression is not too hard to make!

@Ptival
Copy link
Author

Ptival commented Nov 17, 2021

Unless I'm doing something silly, it's actually very simple to reproduce.

On my machine, the following program run in 100s:

  renderIO stdout (layoutPretty @() (LayoutOptions Unbounded) (fillSep (replicate 100000 (pretty "Hello"))))

While the following program runs in 0.05s:

  renderIO stdout (layoutPretty @() (LayoutOptions Unbounded) (hsep (replicate 100000 (pretty "Hello"))))

They produce the exact same output.

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

No branches or pull requests

2 participants