# wolfpld/tracy architecture

> Architecture diagram of the GitHub repository wolfpld/tracy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wolfpld/tracy
- Repository: https://github.com/wolfpld/tracy

## Overview

##### Main Components

a) Client-Side Components:
- Instrumentation Layer (public/tracy/*)
- Language Bindings (C, C++, Lua, Python)
- Data Collection Modules:
- CPU Profiling
- GPU Profiling (Multiple APIs)
- Memory Profiling
- Lock/Threading Analysis
- Context Switch Monitoring

b) Server/Profiler Components:
- Data Reception & Processing (server/*)
- Storage Management (server/TracyMemory.*)
- Worker Thread Management (server/TracyWorker.*)
- Visualization Engine (profiler/src/profiler/*)

##### Data Flow
- Application → Tracy Client Library
- Client Library → Network Transport Layer
- Network Transport → Profiler Application
- Profiler → Storage/Analysis Engine
- Analysis Engine → UI Visualization

##### Key Architectural Elements
- Real-time data streaming system
- Lock-free concurrent queues (public/client/tracy_concurrentqueue.h)
- Memory management system (public/client/tracy_rpmalloc.*)
- Compression pipeline (zstd/*)

**┌─────────────────────────────────────────────┐**
- Target Application             │
- ┬───────────────────────────┘
- ↓
**┌─────────────────────────────────────────────┐**
- Tracy Client SDK               │
- ┬───────────────────────────┤
- CPU Profiling  │      GPU Profiling        │
- Memory Track.  │      Lock Analysis        │
- Context Switch │      Screenshot Capture    │
- ┴───────────────────────────┘
- ↓
**┌─────────────────────────────────────────────┐**
- Network Transport Layer           │
- ┬───────────────────────────┘
- ↓
**┌─────────────────────────────────────────────┐**
- Tracy Profiler UI                │
- ┬───────────────────────────┤
- Data Analysis  │     Timeline View         │
- Visualization  │     Memory Views          │
- Frame Analysis │     Statistics            │
- ┴───────────────────────────┘

##### Important Implementation Details to Note
- Real-time data collection system
- Lock-free architecture for minimal overhead
- Compression for efficient data transfer
- Multiple backend support (OpenGL, Vulkan, DirectX, etc.)
- Cross-platform compatibility

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Target["Target Application"]
        App[Application Code]
    end

    subgraph Client["Tracy Client SDK"]
        direction TB
        Inst["Core Instrumentation"]:::core
        LangBindings["Language Bindings"]:::bindings
        subgraph Profilers["Profiling Systems"]
            direction TB
            CPU["CPU Profiling"]:::profiler
            Mem["Memory Profiling"]:::profiler
            Lock["Lock Analysis"]:::profiler
            Context["Context Switch"]:::profiler
        end
        subgraph GPU["GPU Profiling"]
            direction TB
            Vulkan["Vulkan"]:::gpu
            OpenGL["OpenGL"]:::gpu
            DirectX["DirectX"]:::gpu
        end
    end

    subgraph Transport["Network Transport Layer"]
        Net["Socket Communication"]:::network
        Compress["Compression Pipeline"]:::network
    end

    subgraph Profiler["Tracy Profiler"]
        direction TB
        Worker["Worker Thread Management"]:::backend
        Storage["Storage Management"]:::backend
        subgraph UI["Visualization Layer"]
            direction TB
            Visual["Visualization Engine"]:::ui
            Timeline["Timeline View"]:::ui
            MemView["Memory Views"]:::ui
            Stats["Statistics"]:::ui
        end
    end

    %% Relationships
    App --> Inst
    Inst --> LangBindings
    Inst --> Profilers
    Inst --> GPU
    Profilers --> Net
    GPU --> Net
    Net --> Compress
    Compress --> Worker
    Worker --> Storage
    Storage --> Visual
    Visual --> Timeline
    Visual --> MemView
    Visual --> Stats

    %% Click Events
    click Inst "https://github.com/wolfpld/tracy/blob/master/public/tracy/Tracy.hpp"
    click Mem "https://github.com/wolfpld/tracy/blob/master/public/client/TracyAlloc.cpp"
    click Worker "https://github.com/wolfpld/tracy/blob/master/server/TracyWorker.hpp"
    click Storage "https://github.com/wolfpld/tracy/blob/master/server/TracyMemory.hpp"
    click Visual "https://github.com/wolfpld/tracy/blob/master/profiler/src/profiler/TracyView.hpp"
    click Net "https://github.com/wolfpld/tracy/blob/master/public/common/TracySocket.hpp"
    click LangBindings "https://github.com/wolfpld/tracy/tree/master/public/tracy"
    click Vulkan "https://github.com/wolfpld/tracy/blob/master/public/tracy/TracyVulkan.hpp"
    click OpenGL "https://github.com/wolfpld/tracy/blob/master/public/tracy/TracyOpenGL.hpp"
    click DirectX "https://github.com/wolfpld/tracy/blob/master/public/tracy/TracyD3D12.hpp"
    click Lock "https://github.com/wolfpld/tracy/blob/master/public/client/TracyLock.hpp"
    click Compress "https://github.com/wolfpld/tracy/tree/master/zstd"
    click Timeline "https://github.com/wolfpld/tracy/blob/master/profiler/src/profiler/TracyTimelineController.hpp"

    %% Styling
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef bindings fill:#42A5F5,stroke:#1565C0,color:white
    classDef profiler fill:#64B5F6,stroke:#1565C0,color:white
    classDef gpu fill:#90CAF9,stroke:#1565C0,color:white
    classDef network fill:#757575,stroke:#424242,color:white
    classDef backend fill:#4CAF50,stroke:#2E7D32,color:white
    classDef ui fill:#FF9800,stroke:#F57C00,color:white

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Language Support"]:::bindings
        L3["Profiling Systems"]:::profiler
        L4["GPU Systems"]:::gpu
        L5["Network Layer"]:::network
        L6["Backend Processing"]:::backend
        L7["UI Components"]:::ui
    end
```
