Crates.rs now shows size of the crate and all of its dependencies
-
If a crate directly contains non-Rust code, there's a mini piechart with language breakdown. It uses the same colors as GitHub.
-
Byte size is based on uncompressed source code size. Tests, benches and examples are excluded. Falls back to tarball size for odd crates without source code.
-
Dependencies, ah that's a fun one!
-
Weight of dependencies is based on the full dependency tree (basically all the deps that Cargo would build). Dev deps are excluded.
-
There are many ways to count "size" — download size, compile times, bloat of the final executable. I'm most concerned about the last two, so I'm counting most of the weight from runtime deps.
-
It's an "amortized" weight. If you already have some (sub)dependency in your project, then it doesn't cost anything extra to add another crate using the same dependency. So I adjust weight of a dependency based on its popularity — if a crate is used by 75% of all crates, then I add only 25% of its weight to the overall weight. I also arbitrarily discount weight of optional and platform-specific dependencies.
-
I have some open questions though:
-
What's the size of libc? It compiles down to nothing, but that's still a ton of source code to compile.
-
What's the size of winapi? It's a huge crate, and a few projects include it unconditionally, so you download megabytes of Windows' object files, even on Linux.
-
Should Windows-only dependencies be included in the dependency weight? Linux-only? Even if I evaluate deps for all platforms and take an average, that boils down to adding 1/(number of platforms)th weight of Windows' deps.
-
Some crates contain files that appear to be unused junk. These files are still counted towards crate's weight, mainly because it's nearly impossible to know which files are used and which aren't. I'm not sure what do about them. Hopefully crate authors will notice excessive weight of their crates and exclude the junk?
-
How should I count weight of built-time deps towards the total weight of dependencies? How about proc-macro crates?