Why Cargo Check Is So Slow

(eveeifyeve.pages.dev)

14 points | by eveeifyeve 2 hours ago

8 comments

  • ameliaquining 15 minutes ago
    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?

  • ben_w 2 hours ago
    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.

    • eveeifyeve 1 hour ago
      Also you have the ability to mute it by hovering over music by ... from ... and then a mute button will show.
    • eveeifyeve 2 hours ago
      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...
      • ben_w 1 hour ago
        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.

      • echelon 1 hour ago
        I love the auto-playing music. It reminds me of the Geocities-era web.
        • andrewflnr 38 minutes ago
          Did you actually like it back then?
          • ben_w 27 minutes ago
            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.

  • burnt-resistor 27 minutes ago
    Neat.

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

  • CodesInChaos 53 minutes ago
    Is this complaint only about initial checks? Or also checks after a small change?
  • piinbinary 1 hour ago
    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?
    • Philpax 1 hour ago
      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.

      • LegionMammal978 1 hour ago
        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

      • pjmlp 1 hour ago
        That is an implementation detail, but yeah so far other areas have been given more priority.
      • LoganDark 1 hour ago
        > 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.

        • LegionMammal978 1 hour ago
          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

  • klas_segeljakt 1 hour ago
    #![forbid(proc_macros)]
  • echelon 1 hour ago
    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.

    • tayo42 1 hour ago
      Doesn't that prevent you from using some of the most useful crates?
      • eveeifyeve 1 hour ago
        Kinda but there is good usage of proc macros and bad usage.