通过配置文件引导优化自动化提高 Go 程序的效率

Profile-guided optimization improves the performance of compiled code by using runtime profiling data to inform compiler optimizations. This technique, recently integrated into Go, improves traditional optimizations such as function inlining, basic block and function reordering, register allocation, and more. At Uber, we’ve implemented PGO (profile-guided optimization) in a continuous optimization framework that includes daily profile collection, service-specific enrollment, CI testing, deployment, and performance monitoring. We addressed initial challenges related to increased build times by introducing a profile preprocessing tool, which significantly reduced compilation times. While measuring the impact at a fleet-wide level is difficult, we conducted performance benchmarks and real-world service evaluations at Uber. The results showed efficiency gains and reduced resource utilization for some specific services, validating the effectiveness of PGO-driven optimizations. Support for PGO in Golang was introduced in v1.20 and later improved in later versions through our fruitful collaboration with Google®. This blog describes our experience building core components of PGO and deploying it at Uber.

基于性能分析的优化通过使用运行时分析数据来指导编译器优化,从而提高编译代码的性能。这项技术最近被集成到Go中,改善了传统的优化,如函数内联、基本块和函数重排序、寄存器分配等。在Uber,我们在一个持续优化框架中实现了PGO(基于性能分析的优化),该框架包括每日性能数据收集、特定服务的注册、CI测试、部署和性能监控。我们通过引入性能数据预处理工具来解决与构建时间增加相关的初始挑战,这显著减少了编译时间。虽然在全舰队层面上测量影响是困难的,但我们在Uber进行了性能基准测试和实际服务评估。结果显示某些特定服务的效率提升和资源利用减少,验证了PGO驱动的优化的有效性。对Golang中PGO的支持在v1.20中引入,并通过我们与Google®的成功合作在后续版本中得到了改善。本文描述了我们在Uber构建PGO核心组件和部署的经验。

Profile-guided optimization uses the profile collected during a representative run to generate better code. At a high level, it can be divided into the following phases: profiling, analysis, and recompilation. Multiple languages already support PGO, including C/C++, Rust, Java, and Swift. However, this support was lacking for Golang, which led us to build this functionality in collaboration with Google. 

基于配置文件的优化使用在代表性运行期间收集的配置文件来生成更好的代码。从高层次来看,它可以分为以下几个阶段:分析...

开通本站会员,查看完整译文。

首页 - Wiki
Copyright © 2011-2025 iteam. Current version is 2.142.1. UTC+08:00, 2025-03-15 07:27
浙ICP备14020137号-1 $访客地图$