Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibly reduce crate size #202

Closed
darnuria opened this issue Jul 23, 2020 · 3 comments
Closed

Possibly reduce crate size #202

darnuria opened this issue Jul 23, 2020 · 3 comments

Comments

@darnuria
Copy link
Contributor

darnuria commented Jul 23, 2020

PR: #203

I ran cargo diet --dry-run(cargo diet project) on this crate and seems like it's possible to improve the size of the crate.

By default test are incorporated in the final crate and it can size up significantly the final crate. The rational about that? Not everybody in the world have top notch internet acces or a huge amount of space on the disk.

darnuria/remove-libcλ cargo diet --dry-run
┌────────────────────────────────────────────────────────────┬─────────────┐
│ File                                                       │ Size (Byte) │
├────────────────────────────────────────────────────────────┼─────────────┤
│ .gitignore                                                 │          41 │
│ .evergreen/run-tests.sh                                    │          70 │
│ .evergreen/run-tests-serde.sh                              │          85 │
│ .evergreen/run-tests-u2i.sh                                │          85 │
│ .evergreen/check-rustfmt.sh                                │         121 │
│ src/tests/modules/mod.rs                                   │         123 │
│ src/tests/mod.rs                                           │         155 │
│ .evergreen/check-clippy.sh                                 │         198 │
│ .evergreen/install-dependencies.sh                         │         214 │
│ examples/deserialize.rs                                    │         226 │
│ rustfmt.toml                                               │         236 │
│ src/tests/spec/json/bson-corpus/null.json                  │         258 │
│ src/tests/spec/json/bson-corpus/maxkey.json                │         275 │
│ src/tests/spec/json/bson-corpus/minkey.json                │         275 │
│ .travis.yml                                                │         287 │
│ examples/test.bson                                         │         316 │
│ src/tests/modules/lock.rs                                  │         419 │
│ src/tests/spec/json/bson-corpus/undefined.json             │         425 │
│ src/tests/spec/json/bson-corpus/boolean.json               │         685 │
│ examples/serialize.rs                                      │         705 │
│ etc/update-spec-tests.sh                                   │         838 │
│ src/tests/spec/json/bson-corpus/oid.json                   │         914 │
│ src/tests/spec/mod.rs                                      │        1092 │
│ src/tests/spec/json/bson-corpus/timestamp.json             │        1154 │
│ src/tests/spec/json/bson-corpus/document.json              │        1265 │
│ src/tests/modules/oid.rs                                   │        1290 │
│ src/tests/spec/json/bson-corpus/int32.json                 │        1431 │
│ src/tests/spec/json/bson-corpus/int64.json                 │        1522 │
│ src/tests/spec/json/bson-corpus/datetime.json              │        1710 │
│ src/tests/spec/json/bson-corpus/dbref.json                 │        1994 │
│ src/tests/spec/json/bson-corpus/array.json                 │        2022 │
│ src/tests/spec/json/bson-corpus/code.json                  │        2432 │
│ src/tests/spec/json/bson-corpus/multi-type.json            │        2469 │
│ src/tests/spec/json/bson-corpus/string.json                │        2812 │
│ src/tests/spec/json/bson-corpus/dbpointer.json             │        2819 │
│ src/tests/spec/json/bson-corpus/decimal128-6.json          │        3081 │
│ src/tests/spec/json/bson-corpus/regex.json                 │        3195 │
│ src/tests/spec/json/bson-corpus/symbol.json                │        3232 │
│ src/tests/spec/json/bson-corpus/double.json                │        3527 │
│ src/tests/spec/json/bson-corpus/code_w_scope.json          │        3580 │
│ src/tests/spec/json/bson-corpus/binary.json                │        3831 │
│ .evergreen/config.yml                                      │        4459 │
│ src/tests/modules/bson.rs                                  │        4800 │
│ src/tests/modules/ser.rs                                   │        5094 │
│ src/tests/spec/json/bson-corpus/multi-type-deprecated.json │        5420 │
│ src/tests/modules/ordered.rs                               │        6240 │
│ src/tests/modules/macros.rs                                │        6330 │
│ src/tests/spec/json/bson-corpus/decimal128-4.json          │        7135 │
│ src/tests/spec/corpus.rs                                   │        9534 │
│ src/tests/spec/json/bson-corpus/top.json                   │        9601 │
│ src/tests/spec/json/bson-corpus/bsonview                   │        9647 │
│ src/tests/modules/serializer_deserializer.rs               │       12790 │
│ src/tests/spec/json/bson-corpus/decimal128-7.json          │       12815 │
│ src/tests/serde.rs                                         │       13684 │
│ src/tests/spec/json/bson-corpus/decimal128-1.json          │       17989 │
│ src/tests/spec/json/bson-corpus/decimal128-5.json          │       23341 │
│ src/tests/spec/json/bson-corpus/decimal128-2.json          │       38784 │
│ src/tests/spec/json/bson-corpus/decimal128-3.json          │       90842 │
└────────────────────────────────────────────────────────────┴─────────────┘
Saved 64% or 334.2 KB in 59 files (of 523.7 KB and 80 files in entire crate)

The following change WOULD be made to Cargo.toml:
Diff - removed / added + :
[…skipped 12 lines…]
documentation = "https://docs.rs/crate/bson"
edition = "2018"
+include = ["src/**/*", "LICENSE", "README.md", "!**/tests/*"]

[features]
[…skipped 32 lines…]

If it's okay, I can do a pull-request about it.

Edit

Added link to pull-request

@saghm
Copy link
Contributor

saghm commented Jul 23, 2020

Hmm, I didn't realize that these test files were being included in the final crate. I was under the impression that the Rust test files (e.g. src/tests/mod.rs) wouldn't be included due to them being annotated with #[cfg(test)], and I certainly didn't realize that the non-Rust files would be included as well. We'd definitely be willing to accept a pull request to fix this!

@darnuria darnuria changed the title Reduce crate size Possibly reduce crate size Jul 23, 2020
@darnuria
Copy link
Contributor Author

darnuria commented Aug 1, 2020

#203 is merged, maybe it's time to close this issue if exclusion of the test in the package is enough.

@patrickfreed
Copy link
Contributor

patrickfreed commented Aug 21, 2020

Yep, I think we can close this. Thanks again @darnuria!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants