News for hackers. Stuff that matters.
Re:Why Cargo Check Is So Slow by ameliaquining on Saturday August 09, 2025 @12:11PM (#44847687)
I'm confused about a couple things:

* What is metadata_decode_entry_impl_trait_header and what does it have to do with proc macros? I suppose if a proc macro emitted code that used impl Trait a bunch then it might need to use this code, but I don't see why that would disproportionately affect compile times.

* What's the proposal for how to fix this?

Re:Why Cargo Check Is So Slow by eveeifyeve on Saturday August 09, 2025 @12:58PM (#44848118)
It's used to compile proc macros. in order to fix this typeck needs to not use them which is a huge rewrite alone.
Re:Why Cargo Check Is So Slow by ameliaquining on Saturday August 09, 2025 @10:55PM (#44852436)
In what specific sense is metadata_decode_entry_impl_trait_header "used to compile proc macros" and where did you find this information? And what does the article mean by "and finally it can be fixed"?
Re:Why Cargo Check Is So Slow by ben_w on Saturday August 09, 2025 @10:06AM (#44846564)
What you linked to is a 404.

You're linking to https://eveeifyeve.pages.dev/http://localhost:4321/blogs/car...

You meant to link to https://eveeifyeve.pages.dev/blogs/cargo-check-slow.mdx/

Also, ew, auto-playing music.

Re:Why Cargo Check Is So Slow by eveeifyeve on Saturday August 09, 2025 @11:03AM (#44847063)
Also you have the ability to mute it by hovering over music by ... from ... and then a mute button will show.
Re:Why Cargo Check Is So Slow by eveeifyeve on Saturday August 09, 2025 @10:11AM (#44846600)
Well I will soon have a mute pause and play at the music provided by ... And also I don't see this being linked to: https://eveeifyeve.pages.dev/http://localhost:4321/blogs/car...
Re:Why Cargo Check Is So Slow by ben_w on Saturday August 09, 2025 @10:36AM (#44846814)
When I clicked on it here in HN, that URL (with localhost:4321) was where I went.

Either someone's edited that since then, or a weird auto-redirect on your server happened.

Re:Why Cargo Check Is So Slow by eveeifyeve on Saturday August 09, 2025 @10:47AM (#44846918)
Weird idk blame cloudflare.
Re:Why Cargo Check Is So Slow by echelon on Saturday August 09, 2025 @10:34AM (#44846790)
I love the auto-playing music. It reminds me of the Geocities-era web.
Re:Why Cargo Check Is So Slow by andrewflnr on Saturday August 09, 2025 @11:48AM (#44847439)
Did you actually like it back then?
Re:Why Cargo Check Is So Slow by ben_w on Saturday August 09, 2025 @11:59AM (#44847540)
Back in the late 90s Geocities era, I did like surprise music on personal pages… but also I had bad taste in music at that point because I was an edgy goth teenager with limited experience.

None of us kids back then were any better.

The teachers were going to physically cut the speaker wires in each machine in the computer suite due to all the out-of-sync MIDI renditions of Beverly Hills Cop / Axel F theme before they figured out another solution.

Re:Why Cargo Check Is So Slow by behindsight on Monday August 11, 2025 @03:49AM (#44861703)
probably late but for future reference the reason why HN redirected to the localhost was because you set it as your canonical reference on your site's page.

Might wanna fix that

> <link rel="canonical" href="http://localhost:4321/blogs/cargo-check-slow.mdx/">

Re:Why Cargo Check Is So Slow by burnt-resistor on Saturday August 09, 2025 @11:59AM (#44847545)
Neat.

I use bacon with cargo-make to toggle between check, nextest+doctest, and a full series of pre-commit checks.

Re:Why Cargo Check Is So Slow by CodesInChaos on Saturday August 09, 2025 @11:33AM (#44847311)
Is this complaint only about initial checks? Or also checks after a small change?
Re:Why Cargo Check Is So Slow by piinbinary on Saturday August 09, 2025 @10:53AM (#44846972)
I wonder why procmacros are slow. Can the compiler interpret them or does it have to go to all the work of compiling them before they can run?
Re:Why Cargo Check Is So Slow by Philpax on Saturday August 09, 2025 @10:56AM (#44847006)
It has to compile them; you can see the compiled binaries in your `target` directory. Rust doesn't have an interpreter for the full language, only for the `const` subset, so it can't interpret them.

There have been some proposals to compile the proc-macros to WASM and share those alongside the code in crates.io, but nothing substantial has come of it.

Re:Why Cargo Check Is So Slow by LegionMammal978 on Saturday August 09, 2025 @11:04AM (#44847077)
It does have an interpreter for the full language, that's what Miri uses [0]. In fact, Miri doesn't even have its own evaluator, it just adds additional features to the rustc const-evaluation. The big limitations are that it doesn't have much support for syscalls or other calls into non-Rust code, and it emulates all multithreaded code on a single thread.

[0] https://github.com/rust-lang/miri

Re:Why Cargo Check Is So Slow by Philpax on Saturday August 09, 2025 @02:30PM (#44848884)
Fair enough!
Re:Why Cargo Check Is So Slow by pjmlp on Saturday August 09, 2025 @11:15AM (#44847186)
That is an implementation detail, but yeah so far other areas have been given more priority.
Re:Why Cargo Check Is So Slow by LoganDark on Saturday August 09, 2025 @11:01AM (#44847047)
> Rust doesn't have an interpreter for the full language

Ever since a while ago, rustc uses Miri for const evaluation. So there are a lot of things it can do that it used to not be able to do. But, yes, const evaluation is limited to things that are part of the `const` subset.

Re:Why Cargo Check Is So Slow by LegionMammal978 on Saturday August 09, 2025 @11:07AM (#44847107)
As far as I'm aware, it's always been the other way around: Miri adds some features on top of rustc's const-evaluation code. The limitations of the latter are mainly self-imposed, due to the issues of exposing the different runtime models to programs. (E.g., you don't want to create allocations in const code that get deallocated at runtime.) Indeed, since 2019, the full functionality can be exposed with the unstable -Zunleash-the-miri-inside-of-you flag [0].

[0] https://github.com/rust-lang/rust/pull/56123

Re:Why Cargo Check Is So Slow by LoganDark on Saturday August 09, 2025 @03:50PM (#44849540)
I'm pretty sure we're in agreement? Miri is capable of a lot more but there are self-imposed limitations on what you're allowed to do in const.
Re:Why Cargo Check Is So Slow by klas_segeljakt on Saturday August 09, 2025 @11:06AM (#44847094)
#![forbid(proc_macros)]
Re:Why Cargo Check Is So Slow by echelon on Saturday August 09, 2025 @10:32AM (#44846769)
Feature request: Rust proc macros and compile time statistics need to be called out on crates.io

We're starting to ban them from our Rust monorepo.

Re:Why Cargo Check Is So Slow by tayo42 on Saturday August 09, 2025 @10:40AM (#44846851)
Doesn't that prevent you from using some of the most useful crates?
Re:Why Cargo Check Is So Slow by eveeifyeve on Saturday August 09, 2025 @11:01AM (#44847048)
Kinda but there is good usage of proc macros and bad usage.
Re:Why Cargo Check Is So Slow by kbolino on Saturday August 09, 2025 @01:14PM (#44848267)
In order to collect reliable statistics on compile times, crates.io would have to be doing the compilation themselves. There's no way to trust telemetry from random users, both due to situational variability (individual machine load, overprovisioned CI runner VMs, overcommitted RAM, etc.) and malicious activity. That would mean a significant increase in hosting costs along with a slew of additional work to filter out spam, malware, and DOS attempts, plus building robust data collectors and aggregators.

As to proc macros, I don't think it's possible to implement derive without them. I think it would be fairly easy to detect their presence in a crate at least though.

Both things are also made more complicated by feature flags.

Re:Why Cargo Check Is So Slow by infogulch on Monday August 11, 2025 @12:05PM (#44865828)
Could we use crater runs?
Re:Why Cargo Check Is So Slow by amy_petrik on Sunday August 10, 2025 @07:12PM (#44859233)
we leave poor performance stats and correction as an excercise to the user