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. Boring, but it is the number you actually live with.

So report both, and say which file you touched.

The conversation continues 2

Follow the reasoning
  1. Permalink

    Crystal 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.

Other sides of the same question

  1. 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…