[ANN] TerminalScope.jl - An interface for Profile, SnoopCompile, and Cthulhu

Hi everyone!

I want to announce TerminalScope.jl, an interactive terminal user interface build using Tachikoma.jl (thanks @kahliburke!) to diagnose the performance of Julia code. It bundles four analyses under one macro:

  • Runtime profile: where the time is spent, from the sampling profiler (using Profile);
  • Allocation profile: where the memory is allocated, including what was allocated (using Profile);
  • Inference profile: where the compiler spends its time inferring types (using SnoopCompile);
  • Invalidations: which method definitions invalidate previously compiled code (using SnoopCompile).

On top of those, a type-instability inspector, based on Cthulhu.@descend, shows the source code annotated with the inferred types and lets you descend through the call sites, directly from any profiled frame.

Everything is reached through the @scope macro, whose first argument selects the mode:

using TerminalScope

@scope f(x)                          # Runtime profile (default mode).
@scope allocs f(x)                   # Allocation profile.
@scope inference f(x)                # Type-inference profile.
@scope invalidations using SomePkg   # Method invalidations.
@scope descend f(x)                  # Type-instability inspector.

Each mode opens a full-screen viewer with the frame list on the left and the source code of the selected row, updated live while navigating, on the right. Some highlights:

  • A heat-colored flame graph of the whole profile along the bottom of the screen on terminals with Kitty graphics or Sixel support, following (and clickable to change) the current selection.
  • Mouse support: the wheel scrolls the hovered panel and a click selects a row.
  • Vim-style navigation, whole-tree frame search (including regex) with /, a flat self-time ranking with s, and jump to your editor at the selected frame with e.
  • Dark and light themes, with every color overridable through Preferences.jl.

TerminalScope requires Julia 1.12 or later. I just ask for registration, so it will take 3 days to appear in the General registry.

Feedback, issues, and contributions are very welcome!

10 Likes