11 Profiling Python Application Using Customized CPython 2 Interpreter 胡昊然 华为 CloudBU 性能与工具部 高级工程师

2020-02-27 204浏览

  • 1.Profiling Python Application Using Customized CPython 2 Interpreter 中国Python开发者大会 演讲人:胡昊然
  • 2.PART 01 常见追踪Python 程序手段
  • 3.目前的追踪工具 • Standard Lib • cProfile • profile • Third Party • Pyflame • guppy/heapy • objgraph •… • System Level • GDB • Systemtap/Dtrace •… 缺点: 侵入式更改代码 性能损耗比较大 功能不完善
  • 4.目前的追踪工具 • Standard Lib • cProfile • profile • Third Party • Pyflame • guppy/heapy • objgraph •… • System Level • GDB • Systemtap/Dtrace •… 缺点: 侵入式更改代码 性能损耗比较大 功能不完善 缺点: 性能损耗比较大 功能单一 适合于调试场景
  • 5.目前的追踪工具 • Standard Lib • cProfile • profile • Third Party • Pyflame • guppy/heapy • objgraph •… • System Level • GDB • Systemtap/Dtrace •… 缺点: 侵入式更改代码 性能损耗比较大 功能不完善 缺点: 性能损耗比较大 功能单一 适合于调试场景 缺点: 学习曲线陡峭 扩展困难
  • 6.目前的追踪工具 • Standard Lib • cProfile • profile • Third Party • Pyflame • guppy/heapy • objgraph •… • System Level • GDB • Systemtap/Dtrace •… • 设计目标 • 不需要业务修改代码 • 低性能损耗 • 可扩展性要 • 可接入监控体系
  • 7.PART 02 Python追踪体系的 改造
  • 8.Java调试体系 • JVMTI(JVM Tool Interface) •http://docs.oracle.com/javase/7/docs/platform/jvmti/jvmti.html Java Platform Debugger Architecture(JPDA)
  • 9.模仿Java体系追踪的改造 Python Inside Profiling Architecture
  • 10.对解释器的改造 • 让解释器有机制去提供数据 • 新的特性包括: • 动态加载相关的工具集 • 支持事件驱动的数据收集 • 功能式API
  • 11.功能展示 • 可以实现的功能 • function(函数执行时长,函数调用链) • mem(Python堆大小,关键缓存,各种内存类型 ,系统内存) • exception(异常出现时间,异常堆栈) • thread(线程状态转换) • greenthread(协程状态转换) • osprofiler(Openstack的调用链) •…
  • 12.PART 03 内部用例
  • 13.数据处理的平台 • 数据处理平台 • agent + influxdb + grafana CPython 解 释器 追踪工具 数据清洗程 序 Influxdb Data Processing Flow Grafana
  • 14.通过function工具件发现程序热点 • loong -m _runtime pid load /usr/lib/loong2.7/sitepackages/VonNeumann/function.so
  • 15.通过内存工具件追踪内存使用情况 • loong -m _runtime pid load /usr/lib/loong2.7/sitepackages/VonNeumann/mem.so
  • 16.通过异常组件实时发现程序异常 • loong -m _runtime pid load /usr/lib/loong2.7/sitepackages/VonNeumann/exception.so
  • 17.使用自定义指标组成监控看板
  • 18.感谢聆听! 此处可放 微信二维码 分享人:胡昊然 微信号:vennie1988