On Mon, Aug 10, 2009 at 11:28 PM, Colin McQuillan<m.ni...@googlemail.com> wrote:
> Great news. Could you give a quick summary of how you did it? Yes, I was thinking to write a blog post about this. Maybe we can discuss it here, we'll see if a hash up is worthy of dissemination. Step by step: # Compile for profiling $ make prof-config-hacking $ cabal build # Keep an eye on heap graphs: $ evince yi.ps # Run: $ dist/build/yi/yi +RTS -hd ; make yi.ps Here comes the highly "scientific" part: # Scroll up and down frantically for a few seconds; exit. It's important not to actually insert text here (for now), because that complicates the rest. # Take a look at the graph; notices that some slices "grow up" # constantly over time. (Assume that such a slice is labeled Window in the rest) Now you want to make sure that this really grows. $ dist/build/yi/yi +RTS -hdWindow -hc ; make yi.ps # repeat the frantic scrolling, etc. (further omitted) If this is indeed a leak, it shows a nicely linear graph, broken down by the creator (hc) of the data. You may want to use retainer (hr) or biographical profiling (hb). Unfortunately, neither of these options are going to point directly where the leak appears. Retainers should come close enough, but I noticed that it gives a somewhat approximate result. (It might point to the caller, or to a sibling in the call tree instead of the actual culprit) # Try to remove the part which you think creates the leak, rince, and repeat. > Do you > know if it was a leak I introduced (in Vty) that was causing most of > the slowness, or were all the leaks important? Yep, the leaks around window region calculation were responsible for creating a lot of objects. > Perhaps you could give some tips for Yi developers who want to be sure > they aren't creating bugs in the future. Is just "-hc" cost-center > stack profiling enough? If you trust that you can recognize triangles in the heap graph, that should be ok. This sounds like a joke, but it actually isn't: sometimes a particular slice may be very small (memory footprint), but still correspond to a lot of objects. The leak might become obvious only after so many operations. A script to automate the procedure would greatly help. The most vicious leaks are triggered only by actual keypresses though, so one has to be careful still. Finally, it seems that most leaks (all?) so far were due to too much laziness in the editor state. That's at least something to keep in mind when tracking down such bugs. Hope this helps, JP. --~--~---------~--~----~------------~-------~--~----~ Yi development mailing list yi-devel@googlegroups.com http://groups.google.com/group/yi-devel -~----------~----~----~----~------~----~------~--~---