Home | History | Annotate | Line # | Download | only in pa
      1  1.1  christos # Page Allocator (PA) Microbenchmark Suite
      2  1.1  christos 
      3  1.1  christos This directory contains a comprehensive microbenchmark suite for testing and analyzing jemalloc's Page Allocator (PA) system, including the Hugepage-aware Page Allocator (HPA) and Slab Extent Cache (SEC) components.
      4  1.1  christos 
      5  1.1  christos ## Overview
      6  1.1  christos 
      7  1.1  christos The PA microbenchmark suite consists of two main programs designed to preprocess allocation traces and replay them against jemalloc's internal PA system to measure performance, memory usage, and allocation patterns.
      8  1.1  christos 
      9  1.1  christos To summarize how to run it, assume we have a file `test/stress/pa/data/hpa.csv` collected from a real application using USDT, the simulation can be run as follows:
     10  1.1  christos ```
     11  1.1  christos make tests_pa
     12  1.1  christos ./test/stress/pa/pa_data_preprocessor hpa test/stress/pa/data/hpa.csv test/stress/pa/data/sample_hpa_output.csv
     13  1.1  christos ./test/stress/pa/pa_microbench -p -o test/stress/pa/data/sample_hpa_stats.csv test/stress/pa/data/sample_hpa_output.csv
     14  1.1  christos ```
     15  1.1  christos 
     16  1.1  christos If it's sec, simply replace the first parameter passed to `pa_data_preprocessor` with sec.
     17  1.1  christos 
     18  1.1  christos ## Architecture
     19  1.1  christos 
     20  1.1  christos ### PA System Components
     21  1.1  christos 
     22  1.1  christos The Page Allocator sits at the core of jemalloc's memory management hierarchy:
     23  1.1  christos 
     24  1.1  christos ```
     25  1.1  christos Application
     26  1.1  christos     
     27  1.1  christos Arena (tcache, bins)
     28  1.1  christos     
     29  1.1  christos PA (Page Allocator)  This is what we benchmark
     30  1.1  christos      HPA (Hugepage-aware Page Allocator)
     31  1.1  christos      SEC (Slab Extent Cache)
     32  1.1  christos     
     33  1.1  christos Extent Management (emap, edata)
     34  1.1  christos     
     35  1.1  christos Base Allocator
     36  1.1  christos     
     37  1.1  christos OS (mmap/munmap)
     38  1.1  christos ```
     39  1.1  christos 
     40  1.1  christos ### Microbenchmark Architecture
     41  1.1  christos 
     42  1.1  christos ```
     43  1.1  christos Raw Allocation Traces
     44  1.1  christos     
     45  1.1  christos [pa_data_preprocessor]  Preprocesses and filters traces
     46  1.1  christos     
     47  1.1  christos CSV alloc/dalloc Files
     48  1.1  christos     
     49  1.1  christos [pa_microbench]  Replays against real PA system
     50  1.1  christos     
     51  1.1  christos Performance Statistics & Analysis
     52  1.1  christos ```
     53  1.1  christos 
     54  1.1  christos ## Programs
     55  1.1  christos 
     56  1.1  christos ### 1. pa_data_preprocessor
     57  1.1  christos 
     58  1.1  christos A C++ data preprocessing tool that converts raw allocation traces into a standardized CSV format suitable for microbenchmarking.
     59  1.1  christos 
     60  1.1  christos **Purpose:**
     61  1.1  christos - Parse and filter raw allocation trace data
     62  1.1  christos - Convert various trace formats to standardized CSV
     63  1.1  christos - Filter by process ID, thread ID, or other criteria
     64  1.1  christos - Validate and clean allocation/deallocation sequences
     65  1.1  christos 
     66  1.1  christos ### 2. pa_microbench
     67  1.1  christos 
     68  1.1  christos A C microbenchmark that replays allocation traces against jemalloc's actual PA system to measure performance and behavior with HPA statistics collection.
     69  1.1  christos 
     70  1.1  christos **Purpose:**
     71  1.1  christos - Initialize real PA infrastructure (HPA, SEC, base allocators, emaps)
     72  1.1  christos - Replay allocation/deallocation sequences from CSV traces
     73  1.1  christos - Measure allocation latency, memory usage, and fragmentation
     74  1.1  christos - Test different PA configurations (HPA-only vs HPA+SEC)
     75  1.1  christos - Generate detailed HPA internal statistics
     76  1.1  christos 
     77  1.1  christos **Key Features:**
     78  1.1  christos - **Real PA Integration**: Uses jemalloc's actual PA implementation, not simulation
     79  1.1  christos - **Multi-shard Support**: Tests allocation patterns across multiple PA shards
     80  1.1  christos - **Configurable Modes**: Supports HPA-only mode (`-p`) and HPA+SEC mode (`-s`)
     81  1.1  christos - **Statistics Output**: Detailed per-shard statistics and timing data
     82  1.1  christos - **Configurable Intervals**: Customizable statistics output frequency (`-i/--interval`)
     83  1.1  christos 
     84  1.1  christos ## Building
     85  1.1  christos 
     86  1.1  christos ### Compilation
     87  1.1  christos 
     88  1.1  christos ```bash
     89  1.1  christos # Build both PA microbenchmark tools
     90  1.1  christos cd /path/to/jemalloc
     91  1.1  christos make tests_pa
     92  1.1  christos ```
     93  1.1  christos 
     94  1.1  christos This creates:
     95  1.1  christos - `test/stress/pa/pa_data_preprocessor` - Data preprocessing tool
     96  1.1  christos - `test/stress/pa/pa_microbench` - PA microbenchmark
     97  1.1  christos 
     98  1.1  christos ## Usage
     99  1.1  christos 
    100  1.1  christos ### Data Preprocessing
    101  1.1  christos 
    102  1.1  christos ```bash
    103  1.1  christos # Basic preprocessing
    104  1.1  christos ./test/stress/pa/pa_data_preprocessor <hpa/sec> input_trace.txt output.csv
    105  1.1  christos ```
    106  1.1  christos 
    107  1.1  christos ### Microbenchmark Execution
    108  1.1  christos 
    109  1.1  christos ```bash
    110  1.1  christos # Run with HPA + SEC (default mode)
    111  1.1  christos ./test/stress/pa/pa_microbench -s -o stats.csv trace.csv
    112  1.1  christos 
    113  1.1  christos # Run with HPA-only (no SEC)
    114  1.1  christos ./test/stress/pa/pa_microbench -p -o stats.csv trace.csv
    115  1.1  christos 
    116  1.1  christos # Show help
    117  1.1  christos ./test/stress/pa/pa_microbench -h
    118  1.1  christos ```
    119