mz-profile

Profile Materialize CPU, memory, and binary size using samply, heaptrack, and nm.

6.4k|512|Updated Feb 22, 2019
One-click install
npx skills add https://github.com/MaterializeInc/materialize --skill mz-profile
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mz-profile
Source: https://github.com/MaterializeInc/materialize/tree/main/.agents/skills/mz-profile
Command: npx skills add https://github.com/MaterializeInc/materialize --skill mz-profile

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Diagnosing slow queries, high CPU usage, and excessive memory consumption in Materialize requires the right profiling tools and invocation flags, which are easy to get wrong. This Skill provides the exact commands and workflows for CPU profiling, memory profiling, and binary size analysis of Materialize processes.

Core Features & Use Cases

  • CPU Profiling with samply: Attach to a running process or record environmentd/clusterd from startup, producing Firefox Profiler-compatible flame graphs.
  • Memory Profiling with heaptrack: Capture allocation data from environmentd or clusterd processes and interpret the raw output, plus memory corruption detection via MALLOC_CHECK_ and MALLOC_PERTURB_.
  • Binary Size Analysis: Use nm with demangling and size sorting to identify the largest symbols in a compiled binary.
  • Use Case: When a Materialize deployment shows high memory usage, run heaptrack on the environmentd process and analyze the resulting .raw.zst file to find the allocation hotspots.

Quick Start

Profile the CPU usage of my running Materialize environmentd process and show me a flame graph.

Frequently Asked Questions about mz-profile

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I profile CPU usage of a Materialize process?

Use samply to profile CPU usage: attach to a running process with samply record -p PID, or record environmentd from startup with bin/environmentd --wrapper "samply record". Samply opens an interactive Firefox Profiler flame graph in the browser when recording finishes.

How to check memory usage in Materialize with heaptrack?

Run heaptrack on environmentd with bin/environmentd --reset --no-default-features --wrapper "heaptrack --raw", then analyze the output with heaptrack --interpret on the generated .raw.zst file. Heaptrack works but is slow.

Does Valgrind work for profiling Materialize memory?

Valgrind does not work on Materialize because it is too slow to yield results. Use heaptrack instead, or set MALLOC_CHECK_=3 and MALLOC_PERTURB_=123 with the system allocator to detect some memory corruption issues.

How do I analyze binary size of Rust symbols?

Run nm --demangle=rust --print-size --size-sort --radix=d on the binary to list symbol sizes. Redirect the large output to a file and filter with cut, sort, and uniq to focus on the size of individual symbols.

How do I profile clusterd processes from startup?

Pass the wrapper through the orchestrator: bin/environmentd -- --orchestrator-process-wrapper "samply record" for CPU profiling, or use "heaptrack --raw" as the wrapper for memory profiling of clusterd processes.