Is it good practice to specify just one target for docs.rs?

Most crates are not dependent on the target, by including something like this in your cargo.toml file

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

docs.rs will only generate documentation for a single target.

It seems like if everyone did this, the docs.rs build queue might be shorter, and less electricity would be consumed!

Is this good practice? I think it should be.

3 Likes

we're actually currently discussing making this the default (after an announcement and/or survey), so yes :slight_smile:

edit: this was actually mentioned in an old blog article. Due to the build capacity issue we have at the moment this becomes more pressing.

7 Likes

I created the blog article, we'll do the change to the default targets on May 1st.

1 Like

I don't think this matters since the difference is just one more target, but the default maximum number of build targets of 10 that docs.rs attempts to enforce is actually 11. Specifically if one assigns default-target a target that is distinct from the 10 (distinct) targets in targets; then docs.rs actually builds 11. That may be an "edge case" the team doesn't care about though.

Similarly, when one defines 10 (distinct) targets in targets but doesn't have default-target defined, then the chosen default-target is not the target of the build servers but the first target listed in targets. Again, I imagine such an edge case doesn't need to be called out though.

This is not about the maximum number of targets, but the default targets we build when you don't define any targets in the metadata.

We're building 6 targets by default. After the change, we'll only build one.

Similarly, when one defines 10 (distinct) targets in targets but doesn't have default-target defined, then the chosen default-target is not the target of the build servers but the first target listed in targets. Again, I imagine such an edge case doesn't need to be called out though.

this is intentional. But I didn't want to overcomplicate the blog-post.

That may be an "edge case" the team doesn't care about though.

yep :slight_smile: at least not with as little time as I have with the issues we need to solve :slight_smile:

I know. My comment was somewhat tangential. It's related in that one can further stress docs.rs by "circumventing" the 10-target threshold, and a big part of this change is about reducing the resources docs.rs uses. Please ignore if it's unhelpful as that wasn't my intent.

ah, no worries, valid point.

Most crates don't define a target list, so this change will free up quite some capacity. If crates with manual target lists take too long, we can revisit the other limits.

Fun fact: the highest target count we have in the libc crate, where it's something like 138 ( with extended limits of course).