Memory Profiler

As Julia continues to mature and we build ever more complicated towers of code, it becomes increasingly important for us to ensure that good tools are available for developers to figure out what on earth is going on inside of their programs. To this end, I have spent some time recently instrumenting the garbage collector to track allocations and provide them for analysis in much the same way as our old friend, @profile. The purpose of the tool is to track allocations and frees to allow the canny developer to figure out where memory “leaks” are (e.g. pieces of memory that are still “live” at the end of the instrumented region) as well as portions of high memory churn (E.g. large amounts of objects being allocated/freed).

You can read the pull request description for a more in-depth look at how it works, but the reason I am posting here is that I could use some help pushing this over the finish line. We need some more user-friendly ways of displaying the memory profiler output to the user, and I do not have as much time to create these nice tools now that the actual internals are solid. Examples of what I envision could be useful here are:

  • A text output obtained by converting from the “flat” representation to a “tree” representation just like Profile.view() does.

  • A graphical output that displays information similar to the Google Cloud TPU profiler, which shows memory growth/usage, with information cross-linked between size, location, type, etc…

  • IDE integration, similar to how Juno integrates the time profiler

Again, I’m open to other ideas of what could be useful. Anyone who is interested in chipping away at this with me, don’t hesitate to reach out on the PR, or on slack.

44 Likes

Flame graphs as used in ProfileView and GitHub - tkluck/StatProfilerHTML.jl: Show Julia profiling data in an explorable HTML page should also work, right?

(Super cool btw, thanks!)

3 Likes