Scalene: Scripting-Language Aware Profiling for Python

Emery D. Berger
6/6/2020
20 citations
cs.PLcs.SE

Official code: emeryberger/scalene (238 stars, JavaScript, Apache-2.0, last commit 2025-04-14).

Abstract

Existing profilers for scripting languages (a.k.a. "glue" languages) like Python suffer from numerous problems that drastically limit their usefulness. They impose order-of-magnitude overheads, report information at too coarse a granularity, or fail in the face of threads.

Show full abstract

Worse, past profilers---essentially variants of their counterparts for C---are oblivious to the fact that optimizing code in scripting languages requires information about code spanning the divide between the scripting language and libraries written in compiled languages. This paper introduces scripting-language aware profiling, and presents Scalene, an implementation of scripting-language aware profiling for Python. Scalene employs a combination of sampling, inference, and disassembly of byte-codes to efficiently and precisely attribute execution time and memory usage to either Python, which developers can optimize, or library code, which they cannot. It includes a novel sampling memory allocator that reports line-level memory consumption and trends with low overhead, helping developers reduce footprints and identify leaks. Finally, it introduces a new metric, copy volume, to help developers root out insidious copying costs across the Python/library boundary, which can drastically degrade performance. Scalene works for single or multi-threaded Python code, is precise, reporting detailed information at the line granularity, while imposing modest overheads (26%--53%).

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Scalene: a high-performance, high-precision CPU, GPU, and memory profiler for Python

23811JavaScript, PythonJan 20, 20221 years agoApache-2.0

Similar Papers

Cite this paper

@article{berger2020scalene,
  title  = {Scalene: Scripting-Language Aware Profiling for Python},
  author = {Emery D. Berger},
  year   = {2020},
  eprint = {2006.03879},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2006.03879}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2006.03879.svg)](https://codeofpaper.com/paper/2006.03879)

Discussion