arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2601.10582cs.DCcs.OScs.PF
收藏

缓解边缘AI系统中的GIL瓶颈

Mitigating GIL Bottlenecks in Edge AI Systems

Indian Institute of Information Technology, Allahabad(印度信息技术学院(阿拉哈巴德))

Mridankan Mandal, Smit Sanjay Shende

AI总结:

本文提出了一种轻量级分析工具和自适应运行时系统,通过阻塞比率指标区分真实I/O等待与GIL竞争,实现96.5%的最优性能,优于多进程和异步IO。

摘要:

在资源受限的边缘设备上部署基于Python的AI代理面临关键的运行时优化挑战:高线程数需要掩盖I/O延迟,但Python的全局解释器锁(GIL)会串行化执行。我们证明了朴素的线程池扩展会导致“饱和悬崖”:在边缘代表性配置上,过度配置的线程数(N≥512)会导致性能下降≥20%。我们提出了一种轻量级分析工具和自适应运行时系统,使用阻塞比率指标(beta)区分真实的I/O等待和GIL竞争。我们的库级解决方案在无需手动调优的情况下实现了96.5%的最优性能,优于多进程(受限于约8倍内存开销)和异步IO(在CPU密集型阶段会阻塞)。在七个边缘AI工作负载配置上评估,包括使用ONNX Runtime MobileNetV2的现实ML推理,平均效率达到93.9%。与Python 3.13t(无锁线程)的比较实验表明,尽管消除GIL可使多核边缘设备的吞吐量提高约4倍,但单核设备由于上下文切换开销仍存在饱和悬崖,验证了我们的beta指标在有无GIL环境中的有效性。本文为内存受限的边缘AI系统提供了一种实用的优化策略,其中传统解决方案失效。

英文摘要:

Deploying Python-based AI agents on resource-constrained edge devices presents a critical runtime optimization challenge: high thread counts are needed to mask I/O latency, yet Python's Global Interpreter Lock (GIL) serializes execution. We demonstrate that naive thread pool scaling causes a "saturation cliff": a performance degradation of >= 20% at overprovisioned thread counts (N >= 512) on edge representative configurations. We present a lightweight profiling tool and adaptive runtime system that uses a Blocking Ratio metric (beta) to distinguish genuine I/O wait from GIL contention. Our library-based solution achieves 96.5% of optimal performance without manual tuning, outperforming multiprocessing (which is limited by ~8x memory overhead on devices with 512 MB-2 GB RAM) and asyncio (which blocks during CPU bound phases). Evaluation across seven edge AI workload profiles, including real ML inference with ONNX Runtime MobileNetV2, demonstrates 93.9% average efficiency. Comparative experiments with Python 3.13t (free-threading) show that while GIL elimination enables ~4x throughput on multi-core edge devices, the saturation cliff persists on single-core devices due to context switching overhead, validating our beta metric for both GIL and no-GIL environments. This work provides a practical optimization strategy for memory-constrained edge AI systems where traditional solutions fail.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑