Bytehound Documentation

repository·master·Indexed 26 days ago

https://github.com/koute/bytehound

Bytehound is a high-performance memory profiler for Linux designed to analyze memory leaks, consumption patterns, and fragmentation by tracking allocations and deallocations with stack traces. The repository also includes support for the jemalloc ecosystem (tikv-jemalloc-sys, tikv-jemallocator, and tikv-jemalloc-ctl) and mimalloc integration for Rust and C/C++ projects.

Tokens
43.2K
Snippets
216
Records
358
Agent score
88%

What's inside Bytehound

  1. Overview of the jemalloc support ecosystem

    master

    The jemalloc ecosystem in this repository consists of three main crates:

    • tikv-jemalloc-sys: Builds and links against jemalloc, exposing raw C bindings.
    • tikv-jemallocator: Provides the Jemalloc type which implements the GlobalAlloc and Alloc traits for use as a global allocator.
    • tikv-jemalloc-ctl: A high-level wrapper over jemalloc's control and introspection APIs (the mallctl*() family of functions and the _MALLCTL NAMESPACE).
  2. Overview of Bytehound features

    master

    Bytehound is a memory profiler for Linux that provides:

    • Allocation Tracking: Gathers every allocation and deallocation with full stack traces.
    • Leak & Fragmentation Analysis: Identifies memory leaks, consumption points, temporary allocations, and fragmentation.
    • Performance: Uses a custom stack unwinding implementation designed to be significantly faster than similar tools.
    • Data Export: Supports exporting data as JSON, Heaptrack format (compatible with Heaptrack GUI), and flamegraphs.
    • Analysis Tools: Includes a Web-based GUI and an embedded DSL based on Rhai for programmatic data analysis.
    • Remote Profiling: Can stream profiling data to another machine to save local resources.
    • Architecture Support: AMD64, ARM, AArch64, and MIPS64 (MIPS64 requires a kernel patch for perf_event_open).
    • Allocator Support: Supports applications using jemalloc (AMD64 only, requires jemallocator crate).
  3. Bytehound Documentation Overview

    master

    Bytehound is a memory profiler for Linux. The documentation provides guidance on several key areas:

    • Introduction & Getting Started: Core concepts and initial setup.
    • Case Studies: Practical examples, such as memory leak analysis.
    • Configuration: How to tune the profiler.
    • Troubleshooting: Resolving common issues.
    • API Reference: Detailed documentation for using Bytehound's programmatic interfaces, including globally available functions, core data types like Allocation, AllocationList, Backtrace, Data, Graph, Map, and Duration, and their associated methods.
  4. Build jemalloc for Windows

    master

    To build jemalloc for Windows using MSVC, follow these steps to set up the environment and generate the necessary Visual Studio solution files.

    Prerequisites

    1. Cygwin: Install Cygwin with the following packages:
      • autoconf
      • autogen
      • gawk
      • grep
      • sed
    2. Visual Studio: Install Visual Studio 2015 or 2017 with Visual C++.
    3. Environment: Add Cygwin\bin to your PATH environment variable.

    Build Steps

    1. Open the "x64 Native Tools Command Prompt for VS 2017".
    2. Generate the header files by running:
      sh -c "CC=cl ./autogen.sh"
    3. Open the generated solution file in Visual Studio to build the project: msvc\jemalloc_vc2017.sln
    sh -c "CC=cl ./autogen.sh"
  5. Access or load data using the Data object

    master

    The Data object is used to manage loaded data files within Bytehound. You can interact with it in two ways:

    1. Access existing data: Use the data global to access the currently loaded data file.
    2. Load new data: Use the load global to load a specific data file into the environment.
  6. Add tikv-jemallocator as a dependency

    master

    To use tikv-jemallocator, add it to your Cargo.toml. It is recommended to use a target-specific dependency to avoid issues on MSVC (Windows) platforms, as jemalloc is primarily intended for non-MSVC environments.

    [dependencies]
    
    [target.'cfg(not(target_env = "msvc"))'.dependencies]
    tikv-jemallocator = "0.4.0"