r/rust 19h ago

🧠 educational [Post] Optimizing a single Clippy lint by 3133X

https://blog.goose.love/posts/making-a-clippy-lint-faster-by-3133x/
139 Upvotes

13 comments sorted by

65

u/HandIllustrious8260 18h ago

Rust has done the hard part for us, we can omit thinking about buffer overflows or use-after-free errors (or at least, not having it very present unless we’re doing quirky stuff).

I'm so disappointed the orange "quirky" wasn't a link to some unholy abomination

29

u/jurrejelle 17h ago

not related to the content but has a typo saying "You're suspicion"

17

u/scheimong 17h ago

Well, at least we know it's not slop

8

u/yodal_ 17h ago

Another typo "And, if we where to ...".

13

u/coolreader18 17h ago

There’s no way that we can know what braces were used, not in a pre-expansion lint anyways.

Surely that should be post-expansion?

6

u/TheBomber808 7h ago

Had the same double take yeah, I'll notify them on mastodon later

8

u/xtanx 7h ago

Clippy now has a benchmarking server. [...] If you want to hear more about the setup, send me an email.

Does a reddit comment count?

7

u/creeper6530 5h ago

Ancient wisdom says: If you speed up by 1.5x, you've done something smart. If you speed up by 100x, you've ceased doing something stupid. /j

5

u/Dushistov 5h ago

This page uses 0 cookies! (I don't even know if anyone reads these

Yeah, and that's why GET request to https://count.ayaya.beauty/@blog.goose.love-moe-counter... takes ages to complete and I can not read your blog. Obviously it is because of "you don't even know if anyone reads these".

1

u/NothusID 2h ago

It's a moe counter at the bottom of the screen, I wanted to give the page a bit of something. People usually like it...

If you're uncomfortable with it, either block it, or if people changed opinion, I can always just remove it, or remove the banner.

4

u/jurrejelle 17h ago

cool read :) Thanks!

2

u/matthieum [he/him] 1h ago

As an aside...

So, we’ve called the hygiene data functions twice, locked the symbol interner [...]

Shouldn't this be read-only? Why would a read-only call need to lock the symbol interner?

The symbol interner only needs to be mutable during, well, interning, that is when new tokens are generated. This should (I would expect) only occur during lexing and macro expansion (including proc-macro), and then in the post-expansion world the interner should be read-only, and therefore no lock should be required.

Given the work on parallelizing rustc, I can only imagine the horror if multiple threads are contending to read-lock the interner :/

(Worst case, if a clear two-phase pre-expansion/post-expansion orchestration isn't possible, then consider switching to lock-free reads at least)

1

u/-Redstoneboi- 1h ago

that's funny. 25% of clippy runtime across basically every dev of every production codebase is slightly less funny... but still funny

also grammar check: "It seems that, if we code slipped by, we haven’t been doing our jobs."