Debugging and Profiling

51.1 Debugging

Comma IDE (JetBrains-based Raku IDE) had a debugger and profiler UI. Its commercial development ended in 2024, and the plugin was open-sourced; check the community status. VS Code extensions offer syntax checking and some debugging support.

dd $variable;                    # quick dump with type info (Rakudo)
note $obj.raku;                  # code-like representation to STDERR
say $obj.^name;                  # type name
say Backtrace.new.Str;           # current stack trace
raku-debug script.raku           # interactive debugger (zef install Debugger::UI::CommandLine)
RAKUDO_VERBOSE_STACKFRAME=5 raku script.raku   # more context in error stack frames
raku --ll-exception script.raku  # low-level exception backtrace

51.2 Profiling

raku --profile script.raku                      # produces an HTML profile (call graph, allocations, GC)
raku --profile=profile.sql script.raku          # SQL output for large profiles
raku --profile-compile script.raku              # profile the compilation phase
moarperf profile.sql                            # MoarPerf: a web-based profile viewer (zef install App::MoarVM::Debug / moarperf)
my $start = now;
my $result = (1..100_000).grep(*.is-prime).elems;
say "Took {now - $start} seconds";
use Telemetry;                                  # snapshot CPU/memory usage
say T<cpu wallclock max-rss>;