Home | History | Annotate | only in /src/external/bsd/jemalloc/dist/test/stress/pa
Up to higher level directory
NameDateSize
pa_data_preprocessor.cpp19-Apr-202610.4K
pa_microbench.c19-Apr-202620.3K
README.md19-Apr-20263.5K

README.md

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