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

Pull in fewer dependencies #91

Merged
merged 3 commits into from
Jul 4, 2020
Merged

Pull in fewer dependencies #91

merged 3 commits into from
Jul 4, 2020

Conversation

lopopolo
Copy link
Contributor

@lopopolo lopopolo commented Jul 4, 2020

This PR removes these crates from the dependency tree of version-sync:

  • itertools
  • either
  • aho-corasick
  • thread_local
  • lazy_static

To remove itertools and either, I reimplemented a free function for joining an iterator with a separator. The implementation is short and fairly straightforward, which I hope means the maintenance burden is acceptable. This also allows removing an entire crate with only 15 lines of code.

To remove the remaining dependencies, I deactivated all regex features except std and unicode.

Thank you for the great tests! They made it easy to see what was safe to remove.

lopopolo added 3 commits July 4, 2020 14:14
This removes dependencies on aho-corasick, memchr, thread_local, and
lazy_static.

version-sync is a build and test-time dependency that does not need to
be super fast.
This commit re-implements itertools::join in the helpers module. The
implementation is small -- less than 15 lines of code -- which does not
seem to justify a dependency on an entire external crate.

This enables removing the itertools dependency and transitively removes
either.
regex 1.3 is the first to expose the feature flags we're disabling.

rust-lang/regex#613
@mgeisler
Copy link
Owner

mgeisler commented Jul 4, 2020

Wow, thank you, this looks awesome!

@mgeisler mgeisler merged commit f0d5eb7 into mgeisler:master Jul 4, 2020
@mgeisler
Copy link
Owner

mgeisler commented Jul 4, 2020

I'm not at a computer right now — did you happen to measure the time it takes to compile the crate before and after this change?

@lopopolo
Copy link
Contributor Author

lopopolo commented Jul 4, 2020

Shaves off about 10% of the compile time.

Before

▶ time cargo build
    Updating crates.io index
   Compiling memchr v2.3.3
   Compiling proc-macro2 v1.0.18
   Compiling version_check v0.9.2
   Compiling tinyvec v0.3.3
   Compiling matches v0.1.8
   Compiling unicode-xid v0.2.1
   Compiling serde v1.0.114
   Compiling bitflags v1.2.1
   Compiling pulldown-cmark v0.7.2
   Compiling syn v1.0.33
   Compiling lazy_static v1.4.0
   Compiling regex-syntax v0.6.18
   Compiling percent-encoding v2.1.0
   Compiling either v1.5.3
   Compiling semver-parser v0.9.0
   Compiling unicode-bidi v0.3.4
   Compiling thread_local v1.0.1
   Compiling itertools v0.9.0
   Compiling unicase v2.6.0
   Compiling unicode-normalization v0.1.13
   Compiling aho-corasick v0.7.13
   Compiling quote v1.0.7
   Compiling idna v0.2.0
   Compiling url v2.1.1
   Compiling regex v1.3.9
   Compiling toml v0.5.6
   Compiling version-sync v0.9.0 (/Users/lopopolo/dev/repos/version-sync)
    Finished dev [unoptimized + debuginfo] target(s) in 10.14s

real	0m10.172s
user	1m2.428s
sys	0m3.630s

After

▶ time cargo build
   Compiling proc-macro2 v1.0.18
   Compiling version_check v0.9.2
   Compiling serde v1.0.114
   Compiling memchr v2.3.3
   Compiling tinyvec v0.3.3
   Compiling matches v0.1.8
   Compiling unicode-xid v0.2.1
   Compiling bitflags v1.2.1
   Compiling syn v1.0.33
   Compiling pulldown-cmark v0.7.2
   Compiling regex-syntax v0.6.18
   Compiling percent-encoding v2.1.0
   Compiling semver-parser v0.9.0
   Compiling unicode-bidi v0.3.4
   Compiling unicase v2.6.0
   Compiling unicode-normalization v0.1.13
   Compiling quote v1.0.7
   Compiling idna v0.2.0
   Compiling url v2.1.1
   Compiling regex v1.3.9
   Compiling toml v0.5.6
   Compiling version-sync v0.9.0 (/Users/lopopolo/dev/repos/version-sync)
    Finished dev [unoptimized + debuginfo] target(s) in 8.95s

real	0m8.990s
user	0m49.216s
sys	0m2.899s

@lopopolo
Copy link
Contributor Author

lopopolo commented Jul 4, 2020

When you get a moment, I would be excited to see this released as a v0.9.1 🙏

@mgeisler
Copy link
Owner

mgeisler commented Jul 7, 2020

Thanks for the numbers! I see a similar speedup here. Version 0.9.1 has just been published to crates.io, including another little fix I noticed 🎉

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

Successfully merging this pull request may close these issues.

2 participants