-
Notifications
You must be signed in to change notification settings - Fork 30
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
First naive attempt to generalise the API to support different textual representations #43
base: master
Are you sure you want to change the base?
First naive attempt to generalise the API to support different textual representations #43
Conversation
This looks quite reasonable to me. |
@dterei , do you think this has a chance to be merged or is there anything you would like to see before doing so? |
Firstly, let's not remove Secondly, I'm not sure about using a type-class. It seems reasonable, but we could as easily just add I'd love to understand better first for all of this work:
Sorry to slow you up, but this is a long living problem and potentially a big change, so I'd like to understand the bottom better. Let's keep the discussion mainly in #42. |
I had no idea if (in practice) that was an obsolete relic or something some users could potentially still be using, but I do agree is way more prudent to go through the usual deprecation cycle!
Absolutely! As there is quite an overlap with the discussion in #42 anyway, as you suggested I'm going to simply write a more comprehensive comment there so that we keep the discussion in only one place 😉 |
@adinapoli Anything I should be reviewing or doing with these new commits? |
Hey @dterei ! I have done mostly 2 things:
As you can see so far, the use of |
Yeah, we've had this issue before. Building a benchmark isn't too hard, building one that captures the performance issues that GHC has seen with pretty is far harder... I'm not sure how to help here as I don't know the issues GHC has faced. It seems from our previous analysis that the calls to |
@adinapoli, do you need any help with this? |
Hey @bgamari , thanks for keeping me honest 😉 Yes, a bit of help in gathering realistic, GHC-driven test cases would be awesome indeed. Considering it's not the most rewarding task to do (hehe) and that I'm in the middle of changing jobs, my free time is a bit limited these days 🙈 |
No worries; just let me know if you get stuck. |
@bgamari To be completely clear, currently I feel I'm a bit stuck, in a sense. I don't feel compelled too much in exploring different solutions as I don't have realistic benchmarks which I can leverage. Having those (or at least pointers on how to generate some) would revamp the interest, I guess 😛 |
@adinapoli, quite understandable. It's hard to reduce GHC's use of the pretty-printer to a nice clean benchmark. The bit of GHC that is likely dependent upon pretty-printer performance is the native-code generator (NCG). Here we are constructing assembler programs, which are essentially nothing but If I were to guess, I would try constructing a benchmark that follows roughly the model I describe above: a lot of short lines, each consisting of a few shorts string separated by whitespace. I should note that another option in the cards for GHC is to try swapping out |
FWIW if Text is a problem, forking prettyprinter to use String is simple, but not something I want to have in the Hackage release. |
It does seem like it would be worth trying one of the alternative pretty-printer libraries. Not sure how much work that would be, hopefully only a small amount. Otherwise though, in terms of isolating performance issues in |
Indeed in principle moving to a new pretty-printing library should be fairly straightforward. @bollu is currently trying to do this in D3650. Unfortunately, these sorts of things are never as simple as they seem: currently the branch seems to suffer from what appears to be a code-generation bug (perhaps due to slight differences in assembler output). This is one of many things on my list of things to look into but, as always, help is greatly appreciated. |
Hey all,
following from @bgamari 's feedback, this is a very first, crude attempt to generalise the user-facing API to support multiple textual representations which can be reified back into a normal
String
, but that supports getting the length of the sequence in an efficient way. This PR does two things:It (boldly!) removes the
PStr
constructor fromTextDetails
, as I think it's deprecated anyway and is adding just clutter for nothing.It introduces the
RuneSequence r
typeclass which allows generalising the top level API (things like thetext
combinators) to be independent fromString
.I really hope this is a good step towards the bigger goal of replacing GHC's internal copy of
pretty
with this library 😉Let me know what you guys think!