Code Monkey home page Code Monkey logo

Comments (6)

eigengrau avatar eigengrau commented on July 30, 2024

I was able to get the profiler to take library functions into account as well. While I have library-profiling enabled in my global Cabal config, it seems I had to reinstall dependencies with --ghc-option=-fprof-auto -p.

heap

The textual report can be found here.

COST CENTRE          MODULE                         %time %alloc
wcswidth             Graphics.Text.Width             50.6   42.6
str.theLines         Brick.Widgets.Internal          36.8   34.1
txt                  Brick.Widgets.Internal           7.4   19.2
iso10646String       Graphics.Vty.Image               2.0    3.1
unstreamChunks/inner Data.Text.Internal.Lazy.Fusion   1.3    0.0

from brick.

eigengrau avatar eigengrau commented on July 30, 2024

Tentatively, @8e1d7f4 seems to address the issue. Heap Profiler output showing the retainer of allocations showed that renderFinal seemed to be keeping data from being garbage-collected. I don’t know whether this is the best way to address this, but forcing evaluation on the new render state allows the GC to kick in.

The new profile still shows a largish-seeming memory buildup in the str widget, but after forcing evaluation, the memory is successfully GC’ed.

heap

I don’t understand brick well enough to give a well-founded account of why so much memory was retained there. My hypothesis is that when a widget contains computations that don’t actually go into the render (such as the str widget referencing more lines than can be shown on screen), those references are somehow kept around since the GHC run-time doesn’t know that after an image has been rendered, any left-over computations referenced within the rendering code-path aren’t needed anymore.

from brick.

eigengrau avatar eigengrau commented on July 30, 2024

While the GC can now recycle unneeded computations at the point the image is rendered, str still builds up a considerable amount of thunks for very little input. 6330a59 tries to cut this down by limiting line-rendering computations to only those parts of the string that can actually be rendered.

The str widget computations only appear under the category OTHER on the new heap profile.

heap

This adds a dependency on deepseq, but it can probably be done by spraying bang patterns and seqs around.

from brick.

jtdaugherty avatar jtdaugherty commented on July 30, 2024

Thank you for the report and the terrific investigation. I tend to hate dealing with space leaks so I especially appreciate that you have gone to the trouble to fix this. :)

from brick.

simonmichael avatar simonmichael commented on July 30, 2024

+1, awesome issue report & fix.

from brick.

eigengrau avatar eigengrau commented on July 30, 2024

Cheers! 😸

from brick.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.