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.

The Rust Performance Book (2020)

84 pointsby cwafflesabout 2 years ago

5 comments

asicspabout 2 years ago
Previous discussions: <a href="https:&#x2F;&#x2F;hn.algolia.com&#x2F;?dateRange=all&amp;page=0&amp;prefix=false&amp;query=https%3A%2F%2Fnnethercote.github.io%2Fperf-book%2F&amp;sort=byPopularity&amp;type=story" rel="nofollow">https:&#x2F;&#x2F;hn.algolia.com&#x2F;?dateRange=all&amp;page=0&amp;prefix=false&amp;qu...</a>
评论 #35642660 未加载
kibwenabout 2 years ago
Note that nnethercote is probably the world&#x27;s foremost expert on Rust performance (in addition to being the maintainer of Valgrind). See also his long-running blog series where he discusses his efforts to improve the performance of the Rust compiler itself: <a href="https:&#x2F;&#x2F;nnethercote.github.io&#x2F;2023&#x2F;03&#x2F;24&#x2F;how-to-speed-up-the-rust-compiler-in-march-2023.html" rel="nofollow">https:&#x2F;&#x2F;nnethercote.github.io&#x2F;2023&#x2F;03&#x2F;24&#x2F;how-to-speed-up-the...</a>
cmrdporcupineabout 2 years ago
One thing I&#x27;ve been curious about -- but not enough to actually run through the disassembly yet -- is the performance of Rust matching on enums vs C&#x2F;C++ switch statement -- in particular in e.g. a &#x27;bytecode&#x27; interpreter loop.<p>C compilers do a pretty good job of optimizing these into something pretty efficient, and I imagine it helps that the size of the case values is constant, and it can be turned by the compiler into either a jump table lookup or an unrolled jmp depending on size, etc.<p>Rust enums, in contrast, can be variable sized at match time. And the elements can be nested a few levels deep. The obvious way to write an opcode execution loop in Rust -- a pattern match over an enum of opcodes -- I&#x27;m curious if this can be made to perform as well as in C&#x2F;C++.<p>(I&#x27;ve been writing a virtual machine interpreter loop and so have a modest interest in seeing how this kind of thing, though I&#x27;m not optimizing for performance yet, so)<p>Don&#x27;t see any explicit mention of this in this document.
评论 #35642260 未加载
cwafflesabout 2 years ago
There&#x27;s a good discussion on minimizing heap allocations: <a href="https:&#x2F;&#x2F;nnethercote.github.io&#x2F;perf-book&#x2F;heap-allocations.html" rel="nofollow">https:&#x2F;&#x2F;nnethercote.github.io&#x2F;perf-book&#x2F;heap-allocations.htm...</a>
评论 #35641640 未加载
评论 #35642507 未加载
peoplearepeopleabout 2 years ago
Is there a printed version?
评论 #35643327 未加载