TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Data-driven performance optimization with Rust and Miri

88 pointsby dmitover 2 years ago

9 comments

Arcuruover 2 years ago
&gt; The most surprising thing for me is how unintuitive it is to optimize Rust code given that it’s honestly hard to find a Rust project that doesn’t loudly strive to be “blazingly fast”. No language is intrinsically fast 100% of the time, at least not when a mortal like me is behind the keyboard. It takes work to optimize code, and too often that work is guess-and-check.<p>I get the feeling that a lot of Rust projects claim to be &quot;blazingly fast&quot; just because they are written in Rust, and not because they&#x27;ve made any attempts to actually optimize it. I rarely see any realistic benchmarks, and the few times I&#x27;ve looked deeply into the designs they are not implemented with execution speed in mind, or in some cases prematurely optimized in a way that is actively detrimental [1].<p>Personally I think it&#x27;s because so many of the new Rust programmers are coming from scripting languages, so everything feels fast. I don&#x27;t have any problems with that, but I&#x27;d advise anyone seeing a &quot;blazingly fast&quot; Rust project to check if the project has even a single reasonable benchmark to back that up.<p>[1] <a href="https:&#x2F;&#x2F;jackson.dev&#x2F;post&#x2F;rust-coreutils-dd&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jackson.dev&#x2F;post&#x2F;rust-coreutils-dd&#x2F;</a>
评论 #33923983 未加载
评论 #33924256 未加载
评论 #33924267 未加载
评论 #33924824 未加载
mullrover 2 years ago
Every Linux C&#x2F;C++&#x2F;Rust developer should know about <a href="https:&#x2F;&#x2F;github.com&#x2F;KDAB&#x2F;hotspot" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;KDAB&#x2F;hotspot</a>. It&#x27;s convenient and fast. I use it for Rust all the time, and it provides all of these features on the back of regular old `perf`.
评论 #33924673 未加载
评论 #33928309 未加载
Georgelementalover 2 years ago
Miri is not really meant for performance profiling; it runs on unoptimized MIR, which has very different performance from LLVM-optimized machine code.
评论 #33925181 未加载
评论 #33923802 未加载
评论 #33923541 未加载
gavinrayover 2 years ago
Whaaat, Chrome has a built-in flamegraph profiler that you can use with profiling data from languages like Rust (and presumably others)?!<p>Sweet tip.
评论 #33923188 未加载
评论 #33923711 未加载
评论 #33922657 未加载
评论 #33930912 未加载
lesuoracover 2 years ago
&gt; In order to get any useful results I had to run my Advent of Code solution 1000 times in a loop<p>Yeah that&#x27;s my general problem with all these flamegraphs and other time based tools. There&#x27;s a bunch of noise!<p>I&#x27;d image for something with deterministic GC (or hell no-gc) you should be able to get a &quot;instruction count&quot; based approach that&#x27;d be much more deterministic as to what version of the code is fastest (for that workflow).
评论 #33925130 未加载
评论 #33925867 未加载
评论 #33925156 未加载
评论 #33925207 未加载
评论 #33926158 未加载
ZeroGravitasover 2 years ago
Talking of data driven, I think I read that the rust compiler team checks itself against some massive list of popular crates to check it doesn&#x27;t break anything.<p>Would it be a reasonable use of resources to run all those test suits and identify hot spots for community wide optimization?
评论 #33923400 未加载
评论 #33922670 未加载
zackangeloover 2 years ago
An often overlooked option for profiling Rust is Apple&#x27;s Instruments.app. It&#x27;s amazing and usually the first thing I reach for when I need a profiler on Mac OS X.
评论 #33925079 未加载
LAC-Techover 2 years ago
My key take away from this is different - be very sceptical of third party packages! Both performance issues were traced back to them, and his replacement of their functionality - while not being &quot;battle tested&quot; and surely constituting &quot;re-inventing the wheel&quot; - were faster, easy to read, and easy to understand.<p>Any front-end devs reading this? :)
spullaraover 2 years ago
I&#x27;m surprised there aren&#x27;t CPU emulators that are just for collecting performance information.<p>Edit: Maybe something like this: <a href="https:&#x2F;&#x2F;github.com&#x2F;guillon&#x2F;run-qemu-profile" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;guillon&#x2F;run-qemu-profile</a>
评论 #33928360 未加载