# brendangregg/perf-tools architecture

> Architecture diagram of the GitHub repository brendangregg/perf-tools, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/brendangregg/perf-tools
- Repository: https://github.com/brendangregg/perf-tools

## Overview

##### Main Components Organization

The system should be divided into these primary components:

a) Tool Categories (Main Functional Groups):
- Disk I/O Tools (disk/)
- File System Tools (fs/)
- Network Tools (net/)
- Kernel Tracing Tools (kernel/)
- User Space Tools (user/)
- System Tools (system/)
- Miscellaneous Tools (misc/)

b) Core Infrastructure Components:
- Linux Kernel Interfaces
- ftrace subsystem
- perf_events subsystem
- debugfs interface
- Command-line Interface (bin/)
- Documentation System (man/)

##### Specific Implementation Details

Use these visual elements:
- Blue: ftrace-based tools
- Green: perf_events-based tools
- Yellow: kernel interfaces
- Gray: support components

##### Key Relationships to Highlight

- Tool-to-Kernel Interface:
- How tools connect to either ftrace or perf_events
- Debugfs mount points
- Kernel function probe points

- Data Flow:
- Trace data collection paths
- Post-processing workflows
- Output formatting

##### Implementation Notes

- The non-intrusive nature of the tools
- Real-time monitoring capabilities
- System-wide vs process-specific tracing
- Performance impact warnings

Remember to include the tool examples directory relationship and how it provides usage patterns for each tool, as this is an important part of the project's structure.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef kernel fill:#ffeb99,stroke:#333
    classDef ftrace fill:#b3d9ff,stroke:#333
    classDef perf fill:#b3ffb3,stroke:#333
    classDef interface fill:#f2f2f2,stroke:#333
    classDef docs fill:#e6ccff,stroke:#333
    classDef deprecated fill:#ffcccc,stroke:#333

    %% User Interface Layer
    subgraph CLI
        CMD["Command Line Interface"]:::interface
    end
    click CMD "https://github.com/brendangregg/perf-tools/tree/master/bin/"

    %% Documentation Layer
    subgraph Documentation
        DOCS["Man Pages"]:::docs
        EX["Examples"]:::docs
    end
    click DOCS "https://github.com/brendangregg/perf-tools/tree/master/man/man8/"
    click EX "https://github.com/brendangregg/perf-tools/tree/master/examples/"

    %% Tool Categories Layer
    subgraph Tools
        DISK["Disk I/O Tools"]
        FS["File System Tools"]
        NET["Network Tools"]
        KERN["Kernel Tracing Tools"]
        USER["User Space Tools"]
        SYS["System Tools"]
        MISC["Miscellaneous Tools"]
        DEP["Deprecated Tools"]:::deprecated
    end
    click DISK "https://github.com/brendangregg/perf-tools/tree/master/disk/"
    click FS "https://github.com/brendangregg/perf-tools/tree/master/fs/"
    click NET "https://github.com/brendangregg/perf-tools/tree/master/net/"
    click KERN "https://github.com/brendangregg/perf-tools/tree/master/kernel/"
    click USER "https://github.com/brendangregg/perf-tools/tree/master/user/"
    click SYS "https://github.com/brendangregg/perf-tools/tree/master/system/"
    click MISC "https://github.com/brendangregg/perf-tools/tree/master/misc/"
    click DEP "https://github.com/brendangregg/perf-tools/tree/master/deprecated/"

    %% Tool Implementation Examples
    BITE["bitesize"]:::ftrace
    CACHE["cachestat"]:::ftrace
    TCPR["tcpretrans"]:::ftrace
    FUNC["funccount/funcgraph"]:::ftrace
    UPROBE["uprobe"]:::perf
    TPOINT["tpoint"]:::perf
    PERFHIST["perf-stat-hist"]:::perf
    DEPEX["execsnoop-proc"]:::deprecated

    click BITE "https://github.com/brendangregg/perf-tools/tree/master/disk/bitesize"
    click CACHE "https://github.com/brendangregg/perf-tools/tree/master/fs/cachestat"
    click TCPR "https://github.com/brendangregg/perf-tools/tree/master/net/tcpretrans"
    click FUNC "https://github.com/brendangregg/perf-tools/tree/master/kernel/funccount"
    click UPROBE "https://github.com/brendangregg/perf-tools/tree/master/user/uprobe"
    click TPOINT "https://github.com/brendangregg/perf-tools/tree/master/system/tpoint"
    click PERFHIST "https://github.com/brendangregg/perf-tools/tree/master/misc/perf-stat-hist"
    click DEPEX "https://github.com/brendangregg/perf-tools/tree/master/deprecated/execsnoop-proc"

    %% Kernel Interface Layer
    subgraph Kernel
        FTRACE["ftrace subsystem"]:::kernel
        PERF["perf_events subsystem"]:::kernel
        DEBUGFS["debugfs interface"]:::kernel
    end

    %% Relationships
    CMD --> DISK & FS & NET & KERN & USER & SYS & MISC & DEP
    DISK --> BITE
    FS --> CACHE
    NET --> TCPR
    KERN --> FUNC
    USER --> UPROBE
    SYS --> TPOINT
    MISC --> PERFHIST
    DEP --> DEPEX

    BITE & CACHE & TCPR & FUNC --> FTRACE
    UPROBE & TPOINT & PERFHIST --> PERF
    FTRACE & PERF --> DEBUGFS

    DISK & FS & NET & KERN & USER & SYS & MISC --> DOCS
    DISK & FS & NET & KERN & USER & SYS & MISC --> EX

    %% Legend
    subgraph Legend
        L1["ftrace-based tools"]:::ftrace
        L2["perf_events-based tools"]:::perf
        L3["kernel interfaces"]:::kernel
        L4["deprecated components"]:::deprecated
    end
```
