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

bezierFromSweep very slow? #227

Closed
robx opened this issue Nov 8, 2014 · 5 comments
Closed

bezierFromSweep very slow? #227

robx opened this issue Nov 8, 2014 · 5 comments

Comments

@robx
Copy link
Contributor

robx commented Nov 8, 2014

A program of mine spends far too much time in bezierFromSweep, through expandTrail':

$ less drawpuzzle.prof 
        Sat Nov  8 11:50 2014 Time and Allocation Profiling Report  (Final)

           drawpuzzle +RTS -p -RTS -s wordsearch-crawlgods.pzl

        total time  =        1.72 secs   (1718 ticks @ 1000 us, 1 processor)
        total alloc = 2,864,711,512 bytes  (excludes profiling overheads)

COST CENTRE     MODULE               %time %alloc

bezierFromSweep Diagrams.TwoD.Arc     85.2   88.2
text'           Diagrams.Puzzles.Lib  11.1   11.4

...

                        expandLine.cap                   Diagrams.TwoD.Offset                1584           0    0.0    0.0    86.8   88.4
                         fromLineCap                     Diagrams.TwoD.Offset                1585           0    0.0    0.0    86.8   88.4
                          transform                      Diagrams.Located                    1595           1    0.0    0.0     0.0    0.0
                           transform                     Diagrams.Trail                      1597           1    0.0    0.0     0.0    0.0
                            onTrail                      Diagrams.Trail                      1598           1    0.0    0.0     0.0    0.0
                          capArc                         Diagrams.TwoD.Offset                1586           1    0.0    0.0    86.8   88.4
                           moveOriginTo                  Diagrams.Located                    1596           1    0.0    0.0     0.0    0.0
                           capArc.fs                     Diagrams.TwoD.Offset                1588           1    0.0    0.0    86.8   88.4
                            arcV                         Diagrams.TwoD.Offset                1591           1    0.0    0.0    86.8   88.4
                             angleBetween                Diagrams.Angle                      1610           1    0.0    0.0     0.0    0.0
                              acosA                      Diagrams.Angle                      1611           1    0.0    0.0     0.0    0.0
                             arc                         Diagrams.TwoD.Arc                   1592           1    0.0    0.0    86.8   88.4
                              arcT                       Diagrams.TwoD.Arc                   1601           1    0.0    0.0    86.8   88.4
                               arcT.bs                   Diagrams.TwoD.Arc                   1607           1    0.1    0.0    86.7   88.3
                                bezierFromSweep          Diagrams.TwoD.Arc                   1608        7565   85.2   88.2    86.7   88.3
                                 renderPuzzle            Main                                1816           0    0.0    0.0     0.0    0.0
                                  renderToFile           Diagrams.Puzzles.CmdLine            1817           0    0.0    0.0     0.0    0.0
                                   renderB               Diagrams.Puzzles.CmdLine            1818           0    0.0    0.0     0.0    0.0

(I have no idea what it means for renderPuzzle to show up in that stack...)

I haven't really managed to figure out what's happening, here. This showed up when porting https://github.com/robx/puzzle-draw to the current development version of diagrams; rendering a certain puzzle now gets "stuck" (keeps allocating and slows down to the point of apparently not making progress). I can't be entirely sure this change is due to the new diagrams version, or because of using diagrams-svg instead of diagrams-cairo for the backend. Or something else.

The relevant function in my code is

drawMarkedWord (MW s e) = lwG onepix . stroke $ expandTrail' with {_expandCap = LineCapRound} 0.4 t
     where t = fromVertices [p2i s, p2i e] # translate (r2 (1/2,1/2))

(p2i makes a point from a pair of Ints).

The input file has 18 such marked words, and is rendered fine with the non-updated version. If I replace LineCapRound by LineCapSquare, it works fine.

@cchalmers
Copy link
Member

In ghci:

import Diagrams.Prelude
import Diagrams.TwoD.Offset
expandTrail' (with & expandCap .~ LineCapRound) 0.1 $ (origin ~~ mkP2 1 1.1) -- doesn't hang
expandTrail' (with & expandCap .~ LineCapRound) 0.1 $ (origin ~~ mkP2 1 3) -- hangs

If I had to guess I'd say this is related to #221. Maybe @fryguybob can look into it?

@cchalmers
Copy link
Member

Actually it looks like #221 already fixes it. Do you want to try it out @robx?

@fryguybob
Copy link
Member

Strange. I'm not sure what the hang would be, but the example @cchalmers gave does not hang for me with the arcCCW branch.

@robx
Copy link
Contributor Author

robx commented Nov 8, 2014

Yes, that does appear to fix it. thanks!

@cchalmers
Copy link
Member

Great. The branch should be merged soon.

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