# chaincachemalloc **Repository Path**: jeffreysharp/chaincachemalloc ## Basic Information - **Project Name**: chaincachemalloc - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-30 - **Last Updated**: 2026-04-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## chaincachemalloc(中文说明) 这个仓库用于复现实验并回答一个核心问题:**glibc malloc/free 在 tcache on/off、跨线程 free、以及不同工作集/缓存热度下,长路径/短路径的次数与耗时分别是什么样子**。 ### 目录结构(已清理) - `src/`:基准程序源码(C/C++) - `tcache_chain.c`:链条(pipeline)模型制造跨线程 free - `motivation_bench.cpp`:baseline / pc / alt / freeonly 等模式 - `tcache_mallocfree_single_continuous.cpp`:单线程持续 malloc+free,输出 `alloc_ns/free_ns` - `tcache_freeonly_single.cpp`:较早的 free-only 方向测试(保留以便对照) - `scripts/`:运行与汇总脚本 - `run_tcache_onoff_alloc_free_compare.py`:跑 10 次 on/off,输出 `all_runs.csv` 并画图 - `run_motivation_glibc_stats.sh`、`summarize_motivation_glibc.py`:采集并汇总 `lucifer_malloc_stats` - `visualize_results.py`:老的 `tcache_chain` runs 可视化脚本(保留) - `count_paths.gdb`:用 gdb 精确计数(很慢,只做可行性验证) - `results/`:仅保留**小体积**示例结果(汇总 CSV + 图),不保存巨大原始样本 - `docs/`:补充文档(保留原 `runs/README.zh-CN.md` 为 `runs-README.zh-CN.md`) - **`docs/tcache-onoff-benchmark-and-plots.zh-CN.md`**:tcache on/off 连续 malloc+free 跑分与绘图脚本的完整使用流程 ### 复现:tcache on/off(连续 malloc+free,128B) **完整步骤、默认节控(`--cycle-ms 10 --busy-us 2000`)、`--plots-set minimal`、自动 zoom/diff 窗说明与示例结果**,见 **`docs/tcache-onoff-benchmark-and-plots.zh-CN.md` 第五节**。 快速示例(与文档中「一键 minimal」一致:含 **alloc/free 时序图**、分布 pooled + 自动 zoom、`01_zoom` / `04_diff`): ```bash cd /home/lucifer/Papers/chaincachemalloc mkdir -p build g++ -O2 -g -pthread -std=c++17 \ -o build/tcache_mallocfree_single_continuous \ src/tcache_mallocfree_single_continuous.cpp python3 scripts/run_tcache_onoff_alloc_free_compare.py \ --size 128 \ --duration-sec 5 \ --reps 5 \ --discard 200 \ --pin 0 \ --keep-samples \ --plots-set minimal \ --outdir results/my_tcache_onoff_run ``` - 默认 **`--plots-set default`** 时只生成根目录下汇总图(中位数散点、mean/p99 散点、`alloc_per_rep_timeseries.png`、`free_per_rep_timeseries.png` 等),**不**带 `dist_plots/`、`comparison_views/` 里需读样本的图。 - 若要 **紧循环**(中位数约 20–30 ns、样本量极大),显式加 **`--cycle-ms 0 --busy-us 0`**,并建议增大 `--duration-sec` 或减小 `--discard` 以免单次样本不足 200 行。 输出目录中主要文件: - `all_runs.csv`:每次 rep 的 `median/mean/p99` 与 glibc 计数摘要 - **`minimal` 时**另含:`dist_plots/`、`comparison_views/`,以及 `auto_ranges.txt`、`dist_zoom_auto.txt`(自动窗说明) ### 复现:motivation_bench + glibc 长短路径计数 前提:你有带 `lucifer_malloc_stats` 输出的 glibc,并设置 `MALLOC_LUCIFER_STATS=1`。 ```bash ./scripts/run_motivation_glibc_stats.sh 0,1 ```