Skip to main content
QUICK REVIEW

[论文解读] Need for Speed: A Comprehensive Benchmark of JPEG Decoders in Python

Vladimir Iglovikov|ArXiv.org|Jan 22, 2025
Computational Physics and Python ApplicationsComputer Science被引用 3
一句话总结

本论文在 ARM64 和 x86_64 上对九种 Python JPEG 解码器进行基准测试,显示基于 libjpeg-turbo 的实现解码更快高达 1.5 倍,并给出实用建议。

ABSTRACT

Image loading represents a critical bottleneck in modern machine learning pipelines, particularly in computer vision tasks where JPEG remains the dominant format. This study presents a systematic performance analysis of nine popular Python JPEG decoding libraries on different computing architectures. We benchmark traditional image processing libraries (Pillow, OpenCV), machine learning frameworks (TensorFlow, PyTorch), and specialized decoders (jpeg4py, kornia-rs) on both ARM64 (Apple M4 Max) and x86\_64 (AMD Threadripper) platforms. Our findings reveal that modern implementations using libjpeg-turbo achieve up to 1.5x faster decoding speeds compared to traditional approaches. We provide evidence-based recommendations for choosing optimal JPEG decoders across different scenarios, from high-throughput training pipelines to real-time applications. This comprehensive analysis helps practitioners make informed decisions about image loading infrastructure, potentially reducing training times and improving system efficiency.

研究动机与目标

  • 评估两种架构下主流 Python 库的端到端 JPEG 解码性能。
  • 识别底层解码器(libjpeg 与 libjpeg-turbo)如何影响速度,以及抽象层是否带来开销。
  • 为高吞吐、实时以及开发用例提供实用建议。

提出的方法

  • 在两个平台(ARM64 和 x86_64)基准九种 Python JPEG 解码器。
  • 使用 2000 张 ImageNet 验证图像,分辨率范围从 90x90 到 3264x2792。
  • 测量加载与解码的总时长,每个库进行 20 次运行并进行冷启动缓存清理。
  • 将磁盘 I/O 纳入计时,以反映真实世界使用情况。
  • 比较实现:Pillow、OpenCV、scikit-image、imageio、TensorFlow、torchvision、kornia-rs、jpeg4py 等等。
  • 分析 libjpeg 与 libjpeg-turbo 的影响以及实现语言对性能的影响。
Figure 1: JPEG Decoding Performance on Apple M4 Max
Figure 1: JPEG Decoding Performance on Apple M4 Max

实验结果

研究问题

  • RQ1哪些 Python JPEG 解码器在 ARM64 和 x86_64 上提供最佳端到端解码性能?
  • RQ2底层解码器(libjpeg 与 libjpeg-turbo)如何影响各库的速度?
  • RQ3实现语言和抽象层对解码性能有何影响?
  • RQ4平台差异如何影响 JPEG 解码库的性能?
  • RQ5对于高吞吐流水线与开发使用场景,有哪些实用建议?

主要发现

  • 基于 TurboJPEG 的实现通常在各个平台上表现优于使用标准 libjpeg 的实现(如在 ARM64 上,kornia-rs、OpenCV、 torchvision 属于性能前列)。
  • 在 ARM64(Apple M4 Max)上,前列表现为:kornia-rs 1034 img/秒,OpenCV 1016 img/秒, torchvision 992 img/秒;中等为 imageio 777 img/秒、Pillow 775 img/秒、scikit-image 766 img/秒;TensorFlow 664 img/秒。
  • 在 x86_64(Threadripper)上,前列包括 jpeg4py 和 kornia-rs,并且 OpenCV 占比强;中等包括 torchvision 与 Pillow-SIMD;较低端包括 scikit-image 与 标准 Pillow。
  • 使用 libjpeg-turbo 的库(jpeg4py、kornia-rs、OpenCV、torchvision)在性能上通常优于使用标准 libjpeg 的库(Pillow、imageio、scikit-image)。
  • 现代实现(尤其是基于 Rust 的 kornia-rs)通过降低开销和 SIMD 优化获益,在各平台都达到较高性能。
  • Pillow 保持稳定和兼容性,但通常慢于 TurboJPEG 基于的选项;OpenCV 在计算机视觉工作流中提供强劲性能。
Figure 2: JPEG Decoding Performance on AMD Threadripper 3970X
Figure 2: JPEG Decoding Performance on AMD Threadripper 3970X

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。