Features take time to build. Go through the entire crate graph and figure out which features are on that we don't need. Turn those features off and measure the change in build time and binary size.
I'm not entirely sure how to do this offhand, but here are some ideas.
The most thorough path might be to develop a piece of tooling that captures every feature that is turned on, throughout the crate graph; then investigate each one individually. It might be possible to extend https://github.com/sfackler/cargo-tree to do that.
Otherwise, I'd say start by going through all our direct dependencies, investigating which features are on and whether they can be turned off.
Since most of the features _we've_ explicitly enabled are probably things we want, most changes here will probably be turning off the default features for crates and selecting only the features we want.
After going through our direct dependencies, then do the indirect dependencies. Adjusting features on those may require making them direct dependencies of tikv (not sure).
Measure the compile time and binary size before and after.
Hi! I am a long time admirer of CNCF and their projects. I have a little experience with rust and a lot of free time to work. If someone can mentor me over this issue, I would be glad to work on it!
@psinghal20 Awesome! I'm glad to mentor. This project is going to mostly be about getting to know the crates in our crate graph, understanding whether each of their features _add_ code or _remove_ code, and adjusting them as needed.
Is there anything you need to know to get started?
I was just going to add a note here that this issue also may require turning features _on_ to disable extra code, since there are many "negative" features, like "no_std".
Here's the documentation on cargo features: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section
I'd start by just getting to know the crate graph by installing cargo-tree: cargo install cargo-tree, then running cargo tree in the root directory. Everything it lists is a crate that might have features turned on that we don't need.
Then our [Cargo.toml] file lists its direct dependencies. Those are probably the ones to inspect first because they can easily be changed from our Cargo.toml. Offhand I don't know of a simple way to list, describe and understand the features of a crate but to look at its own Cargo.toml, though often the README.md or API docs for a crate will mention some features. Find a crate's Cargo.toml by searching on https://crates.io/ then clicking either "Repository" , or "Home page" for that crate.
Note that the "components" folder contains several other Rust projects that are dependencies of TiKV.
For this project it would be _very nice_ to have a tool that lists every feature in the crate graph, and indicates whether they are _on_ or _off_. I think it will become difficult to tell which features we've affected without such a tool. I don't know of such a tool, though certainly cargo could be modified to log that info. If you find yourself wanting such a tool, I'd suggest asking in the #cargo Rust discourse channel how to make it.
I'll follow this issue, but if you need to get ahold of me more quickly the best ways are probably to email [email protected] or direct message me on wechat.
Direct deps are now done. There is still opportunity to dig deeper in the crate graph, modify upstream crates to disable default features of _their_ deps, then upgrade them here.
Most helpful comment
@psinghal20 Awesome! I'm glad to mentor. This project is going to mostly be about getting to know the crates in our crate graph, understanding whether each of their features _add_ code or _remove_ code, and adjusting them as needed.
Is there anything you need to know to get started?
I was just going to add a note here that this issue also may require turning features _on_ to disable extra code, since there are many "negative" features, like "no_std".
Here's the documentation on cargo features: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section
I'd start by just getting to know the crate graph by installing cargo-tree:
cargo install cargo-tree, then runningcargo treein the root directory. Everything it lists is a crate that might have features turned on that we don't need.Then our [
Cargo.toml] file lists its direct dependencies. Those are probably the ones to inspect first because they can easily be changed from our Cargo.toml. Offhand I don't know of a simple way to list, describe and understand the features of a crate but to look at its own Cargo.toml, though often the README.md or API docs for a crate will mention some features. Find a crate's Cargo.toml by searching on https://crates.io/ then clicking either "Repository" , or "Home page" for that crate.Note that the "components" folder contains several other Rust projects that are dependencies of TiKV.
For this project it would be _very nice_ to have a tool that lists every feature in the crate graph, and indicates whether they are _on_ or _off_. I think it will become difficult to tell which features we've affected without such a tool. I don't know of such a tool, though certainly cargo could be modified to log that info. If you find yourself wanting such a tool, I'd suggest asking in the #cargo Rust discourse channel how to make it.
I'll follow this issue, but if you need to get ahold of me more quickly the best ways are probably to email [email protected] or direct message me on wechat.