Skip to content
0:00 / 0:00

#rust#wordle#profiling

Implementing and Optimizing a Wordle Solver in Rust

Jon Gjengset

111K subscribers • 38 videos on Hallway

YouTube
  • Recommended by 2 people: 2 in engineering communities.
  • Presented by Jon Gjengset
  • Linked in the descriptionjonhoo/roget

Intermediate. Assumes working knowledge.

181K views4 years ago2 recommendations

Programming languagesTools and practiceRustPerformance and optimizationDebugging

Jon Gjengset live-codes a Wordle solver in Rust and profiles it to achieve a massive performance speedup.

We implement a Wordle solver in Rust based off on the excellent 3blue1brown video on the same topic: youtube.com/watch?v=v68zYyaEmEA And then we profile and optimize it to improve the runtime from our initial naive implementation by ~13500x. You can find the code at github.com/jonhoo/roget. Introduction Wordle intro What we're doing today Gathering our datasets Structure the solver The correctness of a guess Testing the play machinery Outlining the algorithm Does a word match a pattern? Reusing correctness computation Computing a word's "goodness" Running the naive implementation Profiling to the rescue Avoiding allocations Comparing bytes, not characters Correctness computing is faster HashMap iteration is slow Compare bytes again Trying to avoid bounds checks Keep words as length 5 arrays Only initialize remaining once Back to length 5 arrays Where is compute spending time? Short break What if we don't set the first word? What if we start with another word? Precalculating matches Prefer more likely words Prune known-empty patterns Don't even consider unlikely words Closing thoughts Live version with chat: youtu.be/cfjQw4ZjAiI

Why it's here

2 people recommend this

What people say. Highly recommended for learning how to profile and optimize Rust code to find and eliminate performance bottlenecks.

u/1vaderin r/rust • Recommends

On “I created a Wordle bot based on Grant's video!”

In case you haven't seen it, Jon Gjengset did a stream where he implemented and optimized a similar silver based on the ideas from Grant's video. Might be useful as a cross reference and for some optimization ideas (though I guess the mumti-threading part won't work in wasm).

u/misha_hollywoodin r/rust • Recommends

On “What use cases does Rust cover better than Go?”

Not for compare rust performance with go, but for expand rust optimization discussion in similar problem. There is a great stream from Jon, where he explains pretty deeply how to find slow blocks and optimize them link to this video