Scalene based on ChatGPT improves efficiency when programming in Python
A tool from the University of Massachusetts Amherst called Scalene is an AI profiler-“performance troubleshooter”. It has been uploaded to GitHub more than 900,000 times, IT Brew reports.
“It’s great overall and amazing for an academic project.” says UMass professor Emery Berger, who worked with doctoral students Sam Stern and Juan Altmayer Pizzorno on the open-source tool.
According to Berger, Scalene is the first profiler to use AI.
Profilers allow programmers to understand the performance issues of their work and determine which parts of the code take the longest time to execute.
Scalene measures how much time and memory is spent on each line of code – both average and peak.
Languages such as C and C++ are often considered faster and more efficient because the compiler translates the program into machine instructions that are directly executed by the computer.
The standard, popular implementation of Python, known as CPython, is an interpreter that must repeatedly decode instructions. Line-by-line reads increase execution time and significantly degrade performance. For example, slowing down by 20, 50, 100 times.
According to Berger, one of the main tasks of Scalene is not only to find problems line by line, but also to determine how much time is spent on efficient libraries and how much time is spent on Python.
With graphs, the tool tracks memory usage and execution time for each row. It also turns the code into a prompt that triggers recommended changes.
Today’s profilers, which can pinpoint problems and even provide detailed information about inefficiencies, have “last mile problem”, Berger believes.
According to the expert, thanks to Scalene, the user can “use a mechanism supported by ChatGPT to receive an optimization proposal.”
The UMass team won an award for their work on Scalene at the 17th USENIX Symposium on Operating Systems Design and Implementation (OSDI) in July 2023.
“If your Python code is already fast enough, you don’t need a profiler. But if it’s slow, I think it’s a very useful profiler.” – believes Berger.
You can read the report on the best programming languages in 2023 here.