witty-profiler配置指南:从基础设置到生产环境部署
witty-profiler配置指南:从基础设置到生产环境部署
【免费下载链接】witty-profilerThe witty-profiler is an automated data and control stream topology detection and bottleneck analysis tool for AI training and inferencing systems.项目地址: https://gitcode.com/openeuler/witty-profiler
前往项目官网免费下载:https://ar.openeuler.org/ar/
欢迎来到witty-profiler的终极配置指南!🎯 本文将带您从零开始,全面掌握这款强大的AI训练和推理系统性能分析工具的配置方法。无论您是初学者还是经验丰富的系统管理员,都能在这里找到适合您的配置方案。
什么是witty-profiler?🤔
witty-profiler是openEuler社区开发的一款自动化数据和控制流拓扑检测工具,专门为AI训练和推理系统设计。它能自动收集进程关系、IPC活动、设备拓扑和运行时上下文数据,并将这些异构观测结果融合成统一的可分析拓扑图,帮助您快速定位性能瓶颈、重建依赖路径并实现自动化诊断。
📦 基础安装与环境配置
环境要求
witty-profiler支持Python 3.11及以上版本,建议使用uv进行包管理:
# 创建虚拟环境 uv venv .venv --python 3.11 source .venv/bin/activate # 安装核心依赖 uv sync # 安装HTTP服务端支持(可选) uv sync --group server # 安装所有组件 uv sync --group all构建eBPF工具
为了启用底层性能数据采集功能,需要构建eBPF工具:
witty-profiler-build # 或 python -m witty_profiler.tools.build构建完成后,您可以使用--verify参数验证工具状态:
witty-profiler --verify⚙️ 配置文件详解
witty-profiler的配置采用JSON格式,遵循清晰的层级结构。配置文件位于 collector/python/configs/ 目录下。
配置加载优先级
配置按以下优先级加载(高优先级覆盖低优先级):
- CLI命令行参数- 最高优先级
- 配置文件- 通过
--config指定 - 框架默认值- 内置默认配置
核心配置文件结构
完整的配置结构如下:
{ "tmp_dir": "临时文件目录", "server_config": { "server_addr": {"host": "绑定地址", "port": 绑定端口}, "preferred_backend": "后端选择" }, "collector_config": { "disabled_collectors": [], "seed_graph_collectors": [], "remote_slaves": [], "socket_collector_config": {}, "numa_collector_config": {}, "rdma_collector_config": {} }, "sniffer_config": { "socket_sniffer": {}, "cpu_sniffer": {}, "npu_sniffer": {}, "gpu_sniffer": {}, "rdma_sniffer": {} } }快速开始配置
创建一个简单的配置文件my_config.json:
{ "tmp_dir": "local/run/witty_profiler", "server_config": { "server_addr": {"host": "0.0.0.0", "port": 18090} }, "collector_config": { "disabled_collectors": [], "seed_graph_collectors": [ "NPUCollector", "GPUCollector", "RemoteCollector", "NumaCollector", "RDMACollector", "StaticCollector", "CommonProcessParentCollector" ] } }🚀 运行模式配置
离线批量模式
适用于一次性性能分析任务:
# 运行30秒的离线采集 witty-profiler --offline --duration 30 # 监控特定进程 witty-profiler --offline --duration 60 --pid 1234 # 使用自定义配置 witty-profiler --offline --config my_config.json --duration 120HTTP服务模式
启用REST API服务,支持实时监控:
# 启动默认服务(端口18090) witty-profiler # 自定义端口和主机 witty-profiler --host 192.168.1.100 --port 8080 # 使用生产环境配置 witty-profiler --config configs/production.json导出配置模板
# 导出当前完整配置 witty-profiler --dump-config full_config.json # 查看配置优先级 witty-profiler --help | grep config🔧 高级配置选项
采集器配置优化
在 collector/python/configs/collector_config.py 中,您可以微调各种采集器的行为:
Socket采集器配置:
"socket_collector_config": { "enable_thread_node": true, "min_thread_packet_threshold": 10, "enable_filter": true, "filter_conn_packet_cnt": 5, "filter_conn_data_size": 240 }NUMA采集器配置:
"numa_collector_config": { "enable_thread_node": true, "min_thread_ctxt_switch_pct_thresh": 0.1, "min_thread_cpu_pct_thresh": 0.1 }嗅探器性能调优
在 collector/python/configs/sniffer_config.py 中,可以调整底层数据采集参数:
"sniffer_config": { "socket_sniffer": { "monitor_report_maximum_interval_by_second": 2.0, "maximum_dataframe_size_in_seconds": 30, "entry_buffer_size": 20000 }, "cpu_sniffer": { "monitor_report_maximum_interval_by_second": 2.0 }, "gpu_sniffer": { "refresh_interval_by_second": 30.0 } }🏭 生产环境部署指南
安全配置建议
- 网络绑定:在生产环境中,建议绑定到特定IP而非
0.0.0.0 - 权限管理:确保witty-profiler有足够的权限访问系统性能数据
- 日志轮转:配置合理的日志文件大小和轮转策略
{ "tmp_dir": "/var/run/witty_profiler", "server_config": { "server_addr": {"host": "10.0.1.100", "port": 18090} }, "sniffer_config": { "socket_sniffer": { "maximum_log_file_size_in_mb": 500, "maximum_rotation_cnt": 10 } } }分布式监控配置
witty-profiler支持多节点监控配置:
"collector_config": { "remote_slaves": [ { "slave_addr": {"host": "10.0.1.101", "port": 18090}, "query_interval_by_second": 10.0 }, { "slave_addr": {"host": "10.0.1.102", "port": 18090}, "query_interval_by_second": 10.0 } ] }资源限制配置
对于资源受限的环境:
{ "sniffer_config": { "socket_sniffer": { "entry_buffer_size": 10000, # 减少缓冲区大小 "maximum_dataframe_size_in_seconds": 15 # 缩短数据窗口 } }, "collector_config": { "disabled_collectors": ["RDMACollector", "NPUCollector"] # 禁用不需要的采集器 } }🎯 常见配置场景
场景1:快速性能诊断
# 快速启动,监控所有进程 witty-profiler --offline --duration 30 --log-level INFO # 导出诊断配置 witty-profiler --dump-config quick_diagnosis.json场景2:长期监控服务
创建monitoring_config.json:
{ "tmp_dir": "/opt/witty_profiler/data", "server_config": { "server_addr": {"host": "localhost", "port": 18090} }, "sniffer_config": { "socket_sniffer": { "maximum_log_file_size_in_mb": 1000, "maximum_rotation_cnt": 20, "monitor_report_maximum_interval_by_second": 5.0 } } }启动服务:
witty-profiler --config monitoring_config.json场景3:GPU/NPU专用监控
{ "collector_config": { "seed_graph_collectors": [ "NPUCollector", "GPUCollector", "NumaCollector", "SocketCollector", "CommonProcessParentCollector" ] }, "sniffer_config": { "npu_sniffer": { "refresh_interval_by_second": 10.0 # 更频繁的NPU监控 }, "gpu_sniffer": { "refresh_interval_by_second": 10.0 # 更频繁的GPU监控 } } }🔍 配置验证与调试
配置验证命令
# 验证配置语法 python -m witty_profiler.config_manager.validate my_config.json # 查看当前生效的配置 witty-profiler --dump-config current_config.json # 测试特定采集器 witty-profiler --offline --duration 5 --pid $(pgrep python)日志级别设置
witty-profiler支持多种日志级别:
# 详细调试信息 witty-profiler --log-level VERBOSE # 生产环境推荐 witty-profiler --log-level INFO # 仅关键错误 witty-profiler --log-level ERROR📊 性能优化建议
内存优化
- 调整缓冲区大小:根据系统内存调整
entry_buffer_size - 优化数据窗口:平衡
maximum_dataframe_size_in_seconds与内存使用 - 选择性采集:通过
disabled_collectors禁用不需要的采集器
CPU优化
- 调整采集间隔:增加
monitor_report_maximum_interval_by_second减少CPU负载 - 线程级节点控制:根据需求启用/禁用
enable_thread_node - 过滤阈值调整:合理设置
filter_conn_packet_cnt和filter_conn_data_size
🛠️ 故障排除
常见问题
- 权限问题:确保有足够的权限运行eBPF工具
- 端口冲突:检查端口18090是否被占用
- 配置错误:使用
--dump-config验证配置
调试步骤
# 步骤1:验证基础功能 witty-profiler --verify # 步骤2:测试最小配置 witty-profiler --offline --duration 10 --log-level DEBUG # 步骤3:检查日志文件 tail -f /var/log/witty_profiler.log📈 监控与维护
健康检查
# 检查服务状态 curl http://localhost:18090/health # 查看运行统计 curl http://localhost:18090/stats # 获取拓扑图 curl http://localhost:18090/graph定期维护
- 清理临时文件:定期清理
tmp_dir目录 - 日志轮转:配置日志管理系统
- 配置备份:定期备份生产环境配置
🎉 总结
通过本文的指南,您应该已经掌握了witty-profiler从基础配置到生产环境部署的全过程。记住以下关键点:
- 从简单开始:先使用默认配置,再逐步调整
- 理解配置优先级:CLI参数 > 配置文件 > 默认值
- 监控资源使用:根据系统负载调整采集参数
- 利用导出功能:使用
--dump-config了解当前配置
witty-profiler的强大之处在于其灵活的配置系统,让您可以根据不同的AI训练和推理场景进行精准调优。现在就开始配置您的witty-profiler,开启高效的性能分析之旅吧!✨
提示:更多高级配置选项和API文档,请参考项目中的 官方文档 和 配置指南。
【免费下载链接】witty-profilerThe witty-profiler is an automated data and control stream topology detection and bottleneck analysis tool for AI training and inferencing systems.项目地址: https://gitcode.com/openeuler/witty-profiler
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
