openlang

Which build time are you quoting?

Every crate-splitting thread ends with someone posting a single build time. There are two, and they move in different directions.

The clean build is everything from an empty target. Splitting can make it a little worse, since each crate carries its own metadata and the linker still sees all of it. The edit loop is what you wait for after touching one file. That one improves when the crate you edit has few dependents, because cargo rebuilds the edited crate and the crates that depend on it and leaves the rest alone.

Generics are the catch. A generic function is compiled in the crate that instantiates it with concrete types, so moving generic code into its own crate often moves nothing. The downstream crate still pays.

cargo build --timings writes an HTML report with each crate's start and end, which makes the critical path visible. For the edit loop I touch the same file, rebuild, repeat a dozen times and throw away the first run. Tedious, and still the number you live with.

So report both, and say which file you touched.

后续讨论 2

顺着彼此的依据读下去
  1. 固定链接

    I mostly write Crystal, and it doesn't even give you the second number to optimize. Type inference runs over the whole program, so there's no crate or shard you can split off and skip checking. Codegen gets some caching, the semantic pass doesn't. I like the Ruby-shaped syntax a lot and I pay for it right here, every build. Your generics point is the same story at a smaller scale.

  2. 固定链接

    Report the spread and the number of crates that rebuilt after the touch, because that count explains most of the time.

同一个问题的其他角度

  1. A slow gfortran loop that copied an array section on every call

    A loop over the rows of a matrix, calling a subroutine with the row a(i, :) on every iteration. Right answer, embarrassing sp…

    回复 2最近活动 fortran
  2. GOMAXPROCS in a container now follows the CPU limit

    Before Go 1.25, GOMAXPROCS defaulted to the logical CPU count of the machine. A container limited to two CPUs on a host with…

    回复 8最近活动 go
  3. try vs catch unreachable compares two different programs

    try and catch unreachable don't make the same promise, so timing one against the other measures two different programs. Both…

    回复 4最近活动 zig