Use package.include in all published crates#497
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #497 +/- ##
==========================================
+ Coverage 63.23% 63.27% +0.04%
==========================================
Files 36 36
Lines 2377 2377
==========================================
+ Hits 1503 1504 +1
+ Misses 874 873 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #497 will not alter performanceComparing Summary
|
jeertmans
left a comment
There was a problem hiding this comment.
Hi @42triangles, very nice PR! Thanks for your analysis :-)
See my small comment about source files inclusion.
Cargo.toml
Outdated
| repository = "https://github.com/maciejhirsz/logos" | ||
| rust-version = "1.74.0" | ||
| version = "0.15.1" | ||
| include = ["build.rs", "/src", "LICENSE-MIT", "LICENSE-APACHE"] |
There was a problem hiding this comment.
| include = ["build.rs", "/src", "LICENSE-MIT", "LICENSE-APACHE"] | |
| include = ["build.rs", "src/**", "LICENSE-MIT", "LICENSE-APACHE"] |
I think it should be src/**, per https://doc.rust-lang.org/cargo/reference/manifest.html#the-exclude-and-include-fields
There was a problem hiding this comment.
The example on https://doc.rust-lang.org/cargo/reference/manifest.html#the-exclude-and-include-fields is
include = ["/src", "COPYRIGHT", "/examples", "!/examples/big_example"]which also does include the full directory (while src would be equivalent to **/src based on my reading)
There was a problem hiding this comment.
It's just that /src matches any file or directly named src. While src/ matches any directory named src. That's a slight difference that will likely never bother us.
Using stars (src/**) is probably useless if one wants to include everything anyway.
There was a problem hiding this comment.
Which do you prefer? (I personally prefer /src or /src/, but I'm happy to change it to something else too ^^)
|
Though the example from https://doc.rust-lang.org/cargo/reference/manifest.html#the-exclude-and-include-fields also does remind me: With these changes, but the resulting package does not need them to build, so that's probably fine - forgot to mention that earlier, my bad! |
I think it's still very common to include them in the package: I don't know why, but that might be worth it. |
|
With examples & tests added (
It would still be 1.5× the size for (Also I am very confused why |
Did you check what files were included with |
Yup, all tests & examples are included as expected (since it's always relative to the |
This reduces the size of the `logos` considerably, while others
stay the same regarding their compressed size.
Excluding `RELEASE-PROCESS.md`, `book/**`, `logos.svg`, `logos.png`
(this one is especially large) and `release.toml` reduces the compressed
size of the `logos` crate from 1.8MiB to 28.1KiB, resulting in a very
conservative estimate of a reduction of 233.6GiB monthly for downloading
the crate from crates.io (using the number of downloads of the previous
version, as of 2025-08-20).
It would be possible to also remove tests & examples for even further
reductions in size:
without `package.include` with `package.include`
full compressed full compressed
logos-codegen 275.1KiB 54.8KiB 211.0KiB 49.3KiB
logos-derive 20.4KiB 8.0KiB 20.5KiB 8.0KiB
logos 1.8MiB 1.6MiB 59.0KiB 18.9KiB
logos-cli 48.5KiB 15.5KiB 41.4KiB 14.1KiB
Changes of data used in that case:
per dl #dls/month bandwidth/month
logos-codegen -5.5KiB 149416 -802.5MiB
logos-derive ±0.0KiB 149368 ±0.0KiB
logos -1.6MiB 149522 -233.6GiB
logos-cli -l.4KiB 90 -126.0KiB
package.exclude in all published cratespackage.include in all published crates
|
Looks good to me, thanks @42triangles! Maybe we could further optimize this, but that's already big savings in terms of bandwidth :-) |
I came across the issue that the whole
mdbookis included in the published crates during a dependency review, butlogos.pngis especially big and doesn't have to be included for everything to build.This PR makes use of
package.includeto not package these files.The excluded files based on the current version would be:
RELEASE-PROCESS.md,book/**,examples/**,logos.{svg,png},release.toml,tests/**andlogos-{codegen,cli}/tests/**.This reduces the size of almost all crates, but especially
logos(note the change in units):package.includepackage.includelogos-codegenlogos-derivelogoslogos-cliChanges of data used (using the number of downloads of the previous version, as of 2025-8-20):
logos-codegenlogos-derivelogoslogos-cliThough it should be noted that older versions also see a lot of downloads as well, so if the same holds for future versions, the actual bandwidth usage decrease would be much more pronounced over time.
Using all versions over the last 90 days, the
logoscrate would end up with around 2.0TiB/month less bandwidth usage.