Open Source 开源项目 6h ago Updated 4h ago 更新于 4小时前 48

Modernizing the Meta Ads Service With an Open-Source Kernel Scheduler 使用开源内核调度器现代化Meta广告服务平台

Meta utilized sched_ext, a BPF-based extensible scheduling framework, to resolve latency regressions caused by Linux kernel upgrades in their ad serving fleet. The custom scheduling policy achieved a 28% reduction in p99 latency for the ads retrieval stage, resulting in a 1.1% increase in ads ranked and 3.28 MW of power savings. By soft-partitioning CPUs into latency-critical and non-critical pools, the solution improved L3 cache locality and reduced expensive DRAM accesses. Implementing the sch Meta利用基于BPF的sched_ext框架定制广告调度策略,解决了Linux内核升级导致的延迟回归问题。 实施后广告检索阶段P99延迟降低28%,节省3.28兆瓦电力,加权广告排名数量提升1.1%。 后续纯用户态策略更新进一步将P99延迟再降60%,超时错误减少18%,且迭代周期从数月缩短至数天。 sched_ext实现了调度逻辑与内核版本的解耦,使Meta能够独立于上游Linux演进持续优化关键业务负载。

65
Hot 热度
75
Quality 质量
68
Impact 影响力

Analysis 深度分析

TL;DR

  • Meta utilized sched_ext, a BPF-based extensible scheduling framework, to resolve latency regressions caused by Linux kernel upgrades in their ad serving fleet.
  • The custom scheduling policy achieved a 28% reduction in p99 latency for the ads retrieval stage, resulting in a 1.1% increase in ads ranked and 3.28 MW of power savings.
  • By soft-partitioning CPUs into latency-critical and non-critical pools, the solution improved L3 cache locality and reduced expensive DRAM accesses.
  • Implementing the scheduler as a user-space BPF program enabled rapid iteration, allowing subsequent updates to deliver an additional 60% latency reduction and 18% fewer timeouts within days.

Why It Matters

This case study demonstrates how low-level infrastructure optimizations, specifically workload-aware scheduling, can directly translate to significant business value in high-scale distributed systems. It highlights the practical viability of BPF-based kernel extensions for decoupling application-specific performance tuning from upstream kernel release cycles, offering a blueprint for other tech giants managing massive, latency-sensitive workloads.

Technical Details

  • Framework: Utilized sched_ext, an upstream, BPF-based extensible scheduling framework integrated into Linux kernel v6.12, developed in partnership with Google’s ghOSt team.
  • Architecture: The policy soft-partitions CPUs into two dynamic pools based on load-based heuristics: one for latency-critical request path threads and another for less sensitive background work.
  • Implementation: The scheduling logic is implemented as a BPF program loaded via a user-space binary, allowing the kernel to call into the scheduler via event-driven callbacks for thread wake-ups, enqueueing, dispatching, and idle transitions.
  • Performance Metrics: Initial deployment on kernel v6.9 reduced p99 latency by 28%; subsequent user-space-only updates added a further 60% latency reduction and cut timeout errors by 18%.
  • Optimization Mechanism: By keeping related work on the same CPUs over time, the approach maximizes last-level cache (L3) locality, thereby minimizing costly DRAM access patterns.

Industry Insight

  • Decouple Optimization from Kernel Releases: Organizations should consider BPF-based scheduling frameworks to maintain independent optimization paths, avoiding the operational friction and technical debt associated with waiting for upstream kernel updates.
  • User-Space Iteration Speed: Implementing complex system-level policies in user-space (via BPF) drastically reduces the feedback loop for experimentation, enabling daily or weekly performance tweaks instead of multi-month release cycles.
  • Workload-Aware Infrastructure: General-purpose schedulers like CFS or EEVDF may not suffice for extreme-scale, latency-sensitive applications; custom, domain-specific scheduling policies can yield substantial ROI improvements through better resource utilization and cache efficiency.

TL;DR

  • Meta利用基于BPF的sched_ext框架定制广告调度策略,解决了Linux内核升级导致的延迟回归问题。
  • 实施后广告检索阶段P99延迟降低28%,节省3.28兆瓦电力,加权广告排名数量提升1.1%。
  • 后续纯用户态策略更新进一步将P99延迟再降60%,超时错误减少18%,且迭代周期从数月缩短至数天。
  • sched_ext实现了调度逻辑与内核版本的解耦,使Meta能够独立于上游Linux演进持续优化关键业务负载。

为什么值得看

本文展示了如何将底层操作系统调度机制与上层业务指标(如广告收入、延迟)直接挂钩,证明了内核级优化对大规模互联网业务的巨大商业价值。对于基础设施工程师和系统架构师而言,它提供了利用eBPF/sched_ext进行高性能、低侵入式系统优化的最佳实践案例。

技术解析

  • 核心方案:采用Linux内核v6.12引入的sched_ext框架,通过编写BPF程序实现自定义调度策略,替代通用的CFS或EEVDF调度器。
  • 策略逻辑:将CPU软划分为两个池,分别处理延迟敏感型请求线程和非敏感后台任务;利用负载启发式算法动态调整池大小,以维持L3缓存局部性并减少DRAM访问。
  • 部署优势:调度策略作为用户态二进制文件加载,无需重新编译或安装内核即可热更新,极大降低了实验和优化的成本与风险。
  • 性能成果:相比旧版内核+CFS,新方案显著降低了尾部延迟(P99),并通过更高效的资源分配实现了显著的节能效果。

行业启示

  • 业务驱动的基础设施优化:在超大规模系统中,微秒级的系统层优化可直接转化为可量化的商业收益(如广告展示量增加),应建立从业务指标到系统参数的反馈闭环。
  • 解耦与敏捷性:通过eBPF等技术将关键逻辑从内核中剥离至用户态,可实现独立于操作系统发行版的快速迭代,避免被上游内核变更锁定或阻碍。
  • 工作负载感知调度:通用调度器难以满足特定高并发场景需求,针对关键路径(如广告检索)进行工作负载感知的定制化调度是提升整体系统效率的关键方向。

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

Open Source 开源 Deployment 部署 Research 科学研究