Optimized Rust is Still Slower Than Python+NumPy (2024)

[flagged] Optimized Rust is Still Slower Than Python+NumPy (github.com/hirasawakinko)
35 points by akasakahakada on March 30, 2023 | hide | past | favorite | 13comments
Optimized Rust is Still Slower Than Python+NumPy (1)

EwanToo on March 30, 2023 | next [–]


I assume this is in response to https://news.ycombinator.com/item?id=35367520

Optimized Rust is Still Slower Than Python+NumPy (2)

koito17 on March 30, 2023 | prev | next [–]


Ah, the classic problem with benchmarking programming languages.

There may be further optimizations you can do to the Rust code, likewise for Python. I do find it a bit hilarious we are "comparing" Python and Rust because really what this "comparison" lets us conclude is "FFI-ing into a mature Fortran library happens to give faster numerical perf than some Rust solution that is naive in comparison."

Let's see how Rust performs with its own FFI into LAPACK and BLAS. Better yet, since I know people will immediately complain Rust isn't a scripting language, let's try to compare something Lua + Torch against Python + PyTorch. This would be much more "apples-to-apples" than whatever OP is doing at the moment.

Optimized Rust is Still Slower Than Python+NumPy (3)

VHRanger on March 30, 2023 | parent | next [–]


I don't think it matters at the end of the day. Properly written numpy is very fast because it uses MKL or BLAS optimized for relevant architectures.

It won't be worth your while optimizing it unless you need to do something that steps outside the bounds of what numpy can easily do (parallel code, lots of small function calls, etc.)

Optimized Rust is Still Slower Than Python+NumPy (4)

allendoerfer on March 30, 2023 | parent | prev | next [–]


The most useful comparison is between implementations of each ecosystem‘s best practices.

Optimized Rust is Still Slower Than Python+NumPy (5)

jasonpeaco*ck on March 30, 2023 | prev | next [–]


No surprise, because NumPy is implemented with Fortran which is designed to be efficient and fast at mathematical operations. Rust is not. And Python is not either, which is why it uses Fortran under the covers.

I wouldn't be surprised to see Rust numerical libraries created similar to NumPy which also use Fortran, for the same reasons.

If you want a real comparison, try NumPy vs Julia:

https://www.matecdev.com/posts/numpy-julia-fortran.html

Optimized Rust is Still Slower Than Python+NumPy (6)

ummonk on March 30, 2023 | prev | next [–]


This shows a 7x speedup over the "done wrong" code.

Rust called into from Python showed a 100x improvement over the "done wrong" code: https://ohadravid.github.io/posts/2023-03-rusty-python/

So Python+NumPy is significantly slower than Python+Rust. And that's without doing any SIMD in the Rust code, though it's possible the compiler autounrolls and then autovectorizes the loop.

Optimized Rust is Still Slower Than Python+NumPy (7)

ummonk on March 31, 2023 | parent | next [–]


Never mind, I read the numbers wrong.

Optimized Rust is Still Slower Than Python+NumPy (8)

Kwpolska on March 30, 2023 | prev | next [–]


Where's the Rust?

Optimized Rust is Still Slower Than Python+NumPy (9)

justin_oaks on March 30, 2023 | parent | next [–]


Indeed. There isn't sufficient information to understand how the title relates to the link, and what the page linked to is intending to show.

Optimized Rust is Still Slower Than Python+NumPy (10)

re-thc on March 30, 2023 | parent | prev | next [–]


Rusted away

Optimized Rust is Still Slower Than Python+NumPy (11)

akasakahakada on March 30, 2023 | prev | next [–]


Walkthrough:

There is a post today demonstrated that rewriting Python Code in Rust got 100X speed up.

https://news.ycombinator.com/item?id=35367520

(credit to EwanToo, who gave the link first)

Also the original author claimed that Numpy is not worth the effort because it is significantly slower.

So here is the demonstration of a piece of Numpy code, with 350X speed up over the original code.

tldr:

original Python: 1X

original Numpy: 7X

original Rust: 100X

new Numpy: 350X

Optimized Rust is Still Slower Than Python+NumPy (12)

tayo42 on March 30, 2023 | prev | next [–]


Why did this get flagged. Could use some more description but it's pretty interesting

Optimized Rust is Still Slower Than Python+NumPy (13)

Misleading and not even wrong ...

Optimized Rust is Still Slower Than Python+NumPy (2024)
Top Articles
Introduction to Jean Baudrillard, Module on Simulacra and Simulation
Roaming Pokémon
Basic Setup – OpenXR & Pimax HMDs...
Condogames Xyz Discord
Silver Spring, MD to Nanuet, NY Bus
Whiskeytown Camera
3Movierulz
Halloween showing of Hocus Pocus on Thirsks Outdoor cinema, Station Road,Thirsk,YO7 1QL,GB, Northallerton, 11 October 2024
Bank of America Routing Numbers and Wire Transfer Instructions
Craigslist Musicians Delaware
M Life Insider
Ap Spanish Score Calculator
Used Isuzu Trucks For Sale Craigslist
Gpa Calculator Georgia Tech
St Anthony Hospital Crown Point Visiting Hours
Houston Ts Reviews
Punishing Gray Raven Free S Rank
Mail Healthcare Uiowa
Workday Okta Nordstrom
2010 Honda Crv A/C Relay Location
Espn Auction Values
Bj타리
Jailer Showtimes Near Regal Ua Galaxy - Indianapolis
Craigs List Rochester
For Black Boys review: A poignant meditation on black masculinity and mental health
Northern Panhandle West Virginia Craigslist
Piastri vince il Gp di Baku, Leclerc secondo dopo un lungo duello con la McLaren. Incidente tra Perez e Sainz
National Museum of the United States Army
8009405707
Primerica Register
Baptist Primary Care Lakewood
Recruiting: Alabama trying to flip Michigan football's top 2025 commit
Fox 17 Football Blitz
Conan Exiles Change Horse Color
Bostick Tompkins Obituaries
Craigslist For Cleveland Ohio
Ur Cluster Search Engine
Buffalo Allergy Forecast
What Happened To Guy Yovan's Voice
Carthago Chic C-Line PLUS ENKELE BEDDEN + HEFB - Campersite.nl - Campersite: campers en kampeerauto's, met campernieuws en -informatie, techniek, camperplaatsen, occasions, etc.
Daily Incarcerations Tvrj
Paytexaswarrant
Rub Ratings Milwaukee
Enduring Word John 15
Us Open Tennis Sirius Radio
Princessdk
Comment résoudre l'erreur « Could not resolve hostname: nodename nor servname provided, or not known » ?
Cvs Newr.me
Vikram Vedha Download 2022
MLB Probable Pitchers - Starting Pitchers and Matchups
Newjetnet Aa.com
Latest Posts
Article information

Author: Rubie Ullrich

Last Updated:

Views: 5967

Rating: 4.1 / 5 (52 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Rubie Ullrich

Birthday: 1998-02-02

Address: 743 Stoltenberg Center, Genovevaville, NJ 59925-3119

Phone: +2202978377583

Job: Administration Engineer

Hobby: Surfing, Sailing, Listening to music, Web surfing, Kitesurfing, Geocaching, Backpacking

Introduction: My name is Rubie Ullrich, I am a enthusiastic, perfect, tender, vivacious, talented, famous, delightful person who loves writing and wants to share my knowledge and understanding with you.