After fixing it, it apparently runs in 100 ms.
One common pitfall is not turning the optimiser on (with --release for cargo) i.e. benchmarking a debug build rather than a release one, and from a quick glance this code looks like it may be doing a system call to read each and every byte of the file due to the use of .bytes() on an unbuffered file, whereas it would be better to use, say, read_to_end to read many bytes of the file at once.
I am having some trouble reproducing the 2 seconds number, but with optimizations I'm getting around 1.5 seconds (without, I'm up to 5!), and as balducien mentions, /u/DroidLogician pointed out a _huge_ performance flaw in the file reading code.
Writing bad code is easy in any language (as I just showed :) - writing _super_ performant code is only possible in some.
EDIT: I made a pretty bad mistake while writing this comment, claiming that fixing the file reading code improved the speed of the decoder _a lot_, which was not true at all. In fact, the difference is barely (if at all) noticeable when decoding lena.jpeg. However, when reading a larger file, the improvement is definitely there. So sorry! Replying to HN comments while drinking and watching a movie turns out not to be a great idea after all :)
From the article it sounds like the 2s result was for the 90Kb file, which would have been rather odd.
In the "Why" section he claims that Rust is a performant language with a low-level feel.
In this part, he claims that decoding a tiny JPG image took 2 seconds with his code.
How is that "performant" by any definition?