'Python Performance Matters' by Emery Berger (Strange Loop 2022)

preview_player
Показать описание
It's 2022. Moore's Law and Dennard scaling have run out of steam, making it harder than ever to achieve high performance - especially in Python. This talk first explains in detail the unique challenges that Python poses to programmers. It then presents Scalene, a novel high-performance CPU, GPU and memory profiler for Python that does many things that past Python profilers do not and cannot do. Scalene both runs orders of magnitude faster than other profilers while delivering more accurate and more actionable information that's especially valuable to Python programmers.

Emery Berger
Professor, University of Massachusetts Amherst
@emeryberger

-------- Sponsored by: --------

Рекомендации по теме
Комментарии
Автор

Instead of saying "you are writing Python, but you are not writing Python, " it might be better to phrase it as, "you are just using Python to orchestrate highly performant C programs."

jackgenewtf
Автор

Wow, cutting out the questions at the end made the Q&A feel so streamlined. I hope more lecture videos start doing that. Probably saved all viewers 5+ minutes!

Emery gives some fantastic lectures, please invite him back in the future.

ehhhhhhhhhh
Автор

Wow! Big thank you to Prof. Berger and his team for the ground braking profiler from someone who had to upgrade RAM to 64Gb for data science projects. Just tried it and it is a masterpiece. The visual representation of the profiler opens doors into code optimization for everybody.

leonidkerchev
Автор

I have a script with a native backend, pure python backend, and numpy backend that I tested with this profiler. Very interesting results. The numpy implementation, and the pure python implementation both had around 31% native code, despite the numpy implementation being around twice as fast. Scalene showed me a few good places to optimize, and I was able to cut the pure python implementation down from 35 to 25 seconds. The c backend was still about 100x faster (0.2 seconds), with the output "Scalene: Program did not run for long enough to profile."

MrKenkron
Автор

Informative, funny without being lame. The run-time graph was great motivation. It might be even more compelling if you work an actual problem then weave how Scalene addresses the gap in the current Python profiler landscape.

allanwind
Автор

I love Emery Berger, such a charismatic guy and is always working on interesting projects.

hugsun
Автор

Hey, the guy that made the randomizer and Coz! I like this guy, excited for the talk :)

mushchlowastaken
Автор

Small update - Py-spy has multiprocessing. Just use --subprocesses to catch those. I liked way better same output but rendered by pyroscope. Comparison function being really helpfull.

muray
Автор

Love that he mentioned Dennard Scaling. My Parallel Programming prof introduced us to this back in 2016 and made the argument that it was actually the driver for increasing need for parallelized programs.

eexkbzvwpfc
Автор

Violent Agreement haha, super nice tool, makes python even more valuable. The ability to see what your code does is what I need most in a programing language.

GodOfMacro
Автор

I love Emery's talks, always so informative and well-structured

Greenindragon
Автор

I am certainly going to try this. I still prefer C++, but Python has many benefits, especially the ease of getting to work cross platform.

I can write a bit of Python, including optimized modules on a windows 64 bit laptop and then move it to an arm based small form factor computer running Linux. That is certainly possible using C/C++, but there are more steps in compilation and some basic IO issues that always need solving.

juliusfucik
Автор

I was very surprised to see that the `np.array(range(10**7))` in the code example was never addressed.

On my machine, removing the redundant `np.array` call from the `random` line only saved about 2.5 seconds while changing `np.array(range(10**7))` to `np.arange(10**7)` saved almost 8 seconds. Of course the first optimization saved memory, which the second didn’t really do.

rcoder
Автор

Incredibly well explained and engaging. Good stuff 👍

robmckiernan
Автор

Great talk and tool too! Will be trying it out for sure, thanks

Kattemageren
Автор

Great talk! But in my opinion Python does damage the high performance ecosystem (period). While there is a small group of (let's call them) experts (I'd count myself as one) who have spent years in learning language internals and ways to make Python fast (Cython, Numba, numpy gymnastics, Dask, C/C++/Fortran wrappers and so on), the high-level APIs Python offers always come with limitations, are very complex and hard to maintain (lot of different technologies/languages) and newcomers will write code with terrible performance when they implement whatever they need and can't find. That's fact, I am doing code-reviews and reveal from week to week code which runs 10000x slower than it could on clusters with thousands of CPUs, that's just insane. I use python for at least 10 years in scientific programming and have written tons of packages but our students and PhD candidates struggle to squeeze out moderate performance out of Python and need a lot of training. I think it's a waste of time and resources and it's just beating a dead horse. It's time to move forward and be open for alternatives which solve a lot of these issues, like Julia.

tamasgal_com
Автор

Yo. I use scalene everyday. Its dope. Nice to see Emery giving talk. :D

sortof
Автор

27:00 ooh is that why sometimes, it's impossible to CTRL+C a running python program ?

Splatpope
Автор

was very confused when the size of c++ map was compared to a python dictionary. just checked but `sizeof(std::unordered_map<int, int>) is 56`

Snirokok
Автор

I currently do not have access to my big boy pc that has all my big python codebases so I can't be 100% sure but from testing my scripts and such it seems like a cool profiler. Much better than the ones I tried to use before.

Frozander