cargo.git
7 years agoAuto merge of #5168 - Eh2406:faster_resolver, r=alexcrichton
bors [Wed, 14 Mar 2018 16:19:30 +0000 (16:19 +0000)]
Auto merge of #5168 - Eh2406:faster_resolver, r=alexcrichton

Faster resolver: Cache past conflicting_activations, prevent doing the same work repeatedly.

This work is inspired by @alexcrichton's [comment](https://github.com/rust-lang/cargo/issues/4066#issuecomment-303912744) that a slow resolver can be caused by all versions of a dependency being yanked. Witch stuck in my brain as I did not understand why it would happen. If a dependency has no candidates then it will be the most constrained and will trigger backtracking in the next tick. Eventually I found a reproducible test case. If the bad dependency is deep in the tree of dependencies then we activate and backtrack `O(versions^depth)`  times. Even tho it is fast to identify the problem that is a lot of work.

**The set up:**
1. Every time we backtrack cache the (dep, `conflicting_activations`).
2. Build on the work in #5000, Fail to activate if any of its dependencies will just backtrack to this frame. I.E. for each dependency check if any of its cached `conflicting_activations` are already all activated. If so we can just skip to the next candidate. We also add that bad `conflicting_activations` to our set of  `conflicting_activations`, so that we can...

**The pay off:**
 If we fail to find any candidates that we can activate in lite of 2, then we cannot be activated in this context, add our (dep, `conflicting_activations`) to the cache so that next time our parent will not bother trying us.

I hear you saying "but the error messages, what about the error messages?" So if we are at the end `!has_another` then we disable this optimization. After we mark our dep as being not activatable then we activate anyway. It won't resolve but it will have the same error message as before this PR. If we have been activated for the error messages then skip straight to the last candidate, as that is the only backtrack that will end with the user.

I added a test in the vain of #4834. With the old code the time to run was `O(BRANCHING_FACTOR ^ DEPTH)` and took ~3min with DEPTH = 10; BRANCHING_FACTOR = 5; with the new code it runs almost instantly with 200 and 100.

7 years agomore comments
Eh2406 [Wed, 14 Mar 2018 02:44:38 +0000 (22:44 -0400)]
more comments

7 years agoOnly activate for the better error messages if we will bactrack to the user
Eh2406 [Tue, 13 Mar 2018 15:54:21 +0000 (11:54 -0400)]
Only activate for the better error messages if we will bactrack to the user

7 years agotest that cashing works with constraints correctly
Eh2406 [Tue, 13 Mar 2018 15:16:10 +0000 (11:16 -0400)]
test that cashing works with constraints correctly

7 years agoAuto merge of #5152 - matklad:clap, r=alexcrichton
bors [Tue, 13 Mar 2018 14:46:45 +0000 (14:46 +0000)]
Auto merge of #5152 - matklad:clap, r=alexcrichton

Clap

Reopening of #5129

So, looks like all tests are :green_apple: on my machine!

I definitely want to refactor it some more, and also manually checked that we haven't regressed any help messages, but all the major parts are in place already.

7 years agomake sure cashing works whether there is an answer or not
Eh2406 [Mon, 12 Mar 2018 21:36:02 +0000 (17:36 -0400)]
make sure cashing works whether there is an answer or not

7 years agoonly jump to the end if our frame was made for the error message
Eh2406 [Mon, 12 Mar 2018 21:09:01 +0000 (17:09 -0400)]
only jump to the end if our frame was made for the error message

7 years agoFile per command
Aleksey Kladov [Mon, 12 Mar 2018 21:06:04 +0000 (00:06 +0300)]
File per command

7 years agoif a frame will fail make it top priority
Eh2406 [Mon, 12 Mar 2018 20:45:00 +0000 (16:45 -0400)]
if a frame will fail make it top priority

7 years agoUse `avoid_dev_deps` for all commands
Aleksey Kladov [Mon, 12 Mar 2018 20:20:12 +0000 (23:20 +0300)]
Use `avoid_dev_deps` for all commands

7 years agoFix spelling of quiet
Aleksey Kladov [Mon, 12 Mar 2018 20:08:49 +0000 (23:08 +0300)]
Fix spelling of quiet

7 years agoAuto merge of #5167 - xftroxgpx:nosubmodules, r=matklad
bors [Mon, 12 Mar 2018 07:51:14 +0000 (07:51 +0000)]
Auto merge of #5167 - xftroxgpx:nosubmodules, r=matklad

Closes #5165

#5165

7 years agoif we are just here_for the error_messages then only try the last candidate
Eh2406 [Fri, 9 Mar 2018 19:34:45 +0000 (14:34 -0500)]
if we are just here_for the error_messages then only try the last candidate

7 years agocache past conflicting_activations use them to prevent doing the same work repeatedly
Eh2406 [Fri, 2 Mar 2018 01:47:53 +0000 (20:47 -0500)]
cache past conflicting_activations use them to prevent doing the same work repeatedly

7 years agoreduce the mut args to find_candidate
Eh2406 [Tue, 27 Feb 2018 23:09:29 +0000 (18:09 -0500)]
reduce the mut args to find_candidate

7 years agothis test is slow because it runs the same searches repeatedly
Eh2406 [Thu, 22 Feb 2018 17:55:17 +0000 (12:55 -0500)]
this test is slow because it runs the same searches repeatedly

7 years agoCloses #5165
xftroxgpx [Sun, 11 Mar 2018 22:09:57 +0000 (23:09 +0100)]
Closes #5165

7 years agoAuto merge of #5164 - matthiaskrgr:redundant_dep, r=alexcrichton
bors [Sun, 11 Mar 2018 17:54:09 +0000 (17:54 +0000)]
Auto merge of #5164 - matthiaskrgr:redundant_dep, r=alexcrichton

remove "filetime 0.1" dependency from dev profile, filetime is already a regular dep

7 years agoremove "filetime 0.1" dependency from dev profile, filetime is already a regular...
Matthias Krüger [Sun, 11 Mar 2018 14:08:12 +0000 (15:08 +0100)]
remove "filetime 0.1" dependency from dev profile, filetime is already a regular dependency.

7 years agoCleanups
Aleksey Kladov [Sun, 11 Mar 2018 06:38:59 +0000 (09:38 +0300)]
Cleanups

7 years agoRelax tests for windows
Aleksey Kladov [Sat, 10 Mar 2018 15:30:24 +0000 (18:30 +0300)]
Relax tests for windows

On windows, clap prints `cargo.exe` rather than just `cargo`.

7 years agoValidate the limit argument
Aleksey Kladov [Sat, 10 Mar 2018 14:42:08 +0000 (17:42 +0300)]
Validate the limit argument

7 years agoTweak the help message
Aleksey Kladov [Sat, 10 Mar 2018 14:35:18 +0000 (17:35 +0300)]
Tweak the help message

7 years agoMove `index` & `registry` to `ArgMatchesExt`
Aleksey Kladov [Sat, 10 Mar 2018 14:08:39 +0000 (17:08 +0300)]
Move `index` & `registry` to `ArgMatchesExt`

7 years agoMove `new_options` to `ArgMatchesExt`
Aleksey Kladov [Sat, 10 Mar 2018 14:04:06 +0000 (17:04 +0300)]
Move `new_options` to `ArgMatchesExt`

7 years agoMove `compile_options` to `ArgMatchesExt`
Aleksey Kladov [Sat, 10 Mar 2018 13:53:56 +0000 (16:53 +0300)]
Move `compile_options` to `ArgMatchesExt`

7 years agoMake `target` option owned in various configs
Aleksey Kladov [Sat, 10 Mar 2018 13:44:43 +0000 (16:44 +0300)]
Make `target` option owned in various configs

7 years agoMove some arg parsing to ArgMatchesExt
Aleksey Kladov [Sat, 10 Mar 2018 13:39:39 +0000 (16:39 +0300)]
Move some arg parsing to ArgMatchesExt

7 years agoIntroduce ArgMatchesExt trait
Aleksey Kladov [Sat, 10 Mar 2018 13:34:28 +0000 (16:34 +0300)]
Introduce ArgMatchesExt trait

7 years agoInline `config_from_args`
Aleksey Kladov [Sat, 10 Mar 2018 13:25:42 +0000 (16:25 +0300)]
Inline `config_from_args`

7 years agoRename CommonArgs -> AppExt
Aleksey Kladov [Sat, 10 Mar 2018 13:23:30 +0000 (16:23 +0300)]
Rename CommonArgs -> AppExt

7 years agoReorganize subcommands as a separate submodule
Aleksey Kladov [Sat, 10 Mar 2018 13:23:05 +0000 (16:23 +0300)]
Reorganize subcommands as a separate submodule

7 years agoMove command_prelude to a separate file
Aleksey Kladov [Sat, 10 Mar 2018 13:16:00 +0000 (16:16 +0300)]
Move command_prelude to a separate file

7 years agoIntroduce command_prelude module
Aleksey Kladov [Sat, 10 Mar 2018 13:13:51 +0000 (16:13 +0300)]
Introduce command_prelude module

7 years agoAuto merge of #5160 - ishitatsuyuki:patch-1, r=matklad
bors [Sat, 10 Mar 2018 06:32:57 +0000 (06:32 +0000)]
Auto merge of #5160 - ishitatsuyuki:patch-1, r=matklad

Remove unused import

7 years agoRemove unused import
Tatsuyuki Ishi [Sat, 10 Mar 2018 06:21:25 +0000 (15:21 +0900)]
Remove unused import

7 years agoAuto merge of #5159 - ishitatsuyuki:patch-1, r=Mark-Simulacrum
bors [Sat, 10 Mar 2018 02:18:39 +0000 (02:18 +0000)]
Auto merge of #5159 - ishitatsuyuki:patch-1, r=Mark-Simulacrum

Remove redundant recursion_limit

Now that we have migrate from error-chain to failure, we no longer need to extend it.

7 years agoRemove redundant recursion_limit
Tatsuyuki Ishi [Sat, 10 Mar 2018 02:06:06 +0000 (11:06 +0900)]
Remove redundant recursion_limit

Now that we have migrate from error-chain to failure, we no longer need to extend it.

7 years agoAuto merge of #5126 - gilescope:cycle-error-message, r=alexcrichton
bors [Fri, 9 Mar 2018 19:40:03 +0000 (19:40 +0000)]
Auto merge of #5126 - gilescope:cycle-error-message, r=alexcrichton

Error message for package "depends on itself" lists the packages in the cycle.

I got a cycle while trying to build someone else's code and cargo's error message didn't point me in the right direction, just mentioned there was a cycle. I thought we could be a bit more helpful.

Don't know what you think of {:#?} as the display but it seemed minimal code so I thought I'd start with that. I could compress the output to one package per line if preferred.

7 years agoClippy complains about unused in derived code.
Giles Cope [Fri, 9 Mar 2018 18:32:28 +0000 (18:32 +0000)]
Clippy complains about unused in derived code.

7 years agoAuto merge of #5157 - Eh2406:more_interning, r=alexcrichton
bors [Fri, 9 Mar 2018 17:56:35 +0000 (17:56 +0000)]
Auto merge of #5157 - Eh2406:more_interning, r=alexcrichton

More interning

This is a forward approach to interning. Specifically `Dependency` and `PackageId` store their names as `InternedString`s and leave that value interned as long as possible. The alternative is to make a new `interned_name` function. The advantage of this approach is that a number of places in the code are doing `deb.name() == pid.name()` and are now using the fast pointer compare instead of the string compare, without the code needing to change. The disadvantage is that lots of places need to call `deref` with `&*` to convert to an `&str` and sum need to use `.to_inner()` to get a `&'static str`.

In a test on https://github.com/rust-lang/cargo/issues/4810#issuecomment-357553286
Before we got to 10000000 ticks in ~48 sec
After we got to 10000000 ticks in ~44 sec

7 years agodelay calls to `to_inner`
Eh2406 [Fri, 9 Mar 2018 16:47:10 +0000 (11:47 -0500)]
delay calls to `to_inner`

7 years agoDependency.name to InternedString
Eh2406 [Fri, 9 Mar 2018 15:07:59 +0000 (10:07 -0500)]
Dependency.name to InternedString

7 years agoMake command-line arguments owned
Aleksey Kladov [Fri, 9 Mar 2018 10:18:32 +0000 (13:18 +0300)]
Make command-line arguments owned

7 years agoValidate that `jobs` argument is a number
Aleksey Kladov [Fri, 9 Mar 2018 08:03:36 +0000 (11:03 +0300)]
Validate that `jobs` argument is a number

7 years agoUnwind stack for cli errors
Aleksey Kladov [Fri, 9 Mar 2018 07:43:00 +0000 (10:43 +0300)]
Unwind stack for cli errors

7 years agoPackageId.name to InternedString
Eh2406 [Thu, 8 Mar 2018 21:24:27 +0000 (16:24 -0500)]
PackageId.name to InternedString

7 years agoRemove dead code
Aleksey Kladov [Thu, 8 Mar 2018 20:41:26 +0000 (23:41 +0300)]
Remove dead code

7 years agoRemove docopt dependency
Aleksey Kladov [Thu, 8 Mar 2018 20:37:39 +0000 (23:37 +0300)]
Remove docopt dependency

7 years agoFix after rebase
Aleksey Kladov [Thu, 8 Mar 2018 20:33:52 +0000 (23:33 +0300)]
Fix after rebase

7 years agoFix typo
Aleksey Kladov [Thu, 8 Mar 2018 20:29:38 +0000 (23:29 +0300)]
Fix typo

7 years agoRemove dead code
Aleksey Kladov [Thu, 8 Mar 2018 20:26:52 +0000 (23:26 +0300)]
Remove dead code

7 years agoFix `--explain`
Aleksey Kladov [Thu, 8 Mar 2018 20:24:27 +0000 (23:24 +0300)]
Fix `--explain`

7 years agoSupport list subcommand
Aleksey Kladov [Thu, 8 Mar 2018 20:19:27 +0000 (23:19 +0300)]
Support list subcommand

All tests are green :tada:

7 years agoSupport aliases
Aleksey Kladov [Thu, 8 Mar 2018 20:06:29 +0000 (23:06 +0300)]
Support aliases

7 years agoFix more tests by updating error messages
Aleksey Kladov [Thu, 8 Mar 2018 19:40:28 +0000 (22:40 +0300)]
Fix more tests by updating error messages

7 years agoUnignore test which now passes
Aleksey Kladov [Thu, 8 Mar 2018 19:36:27 +0000 (22:36 +0300)]
Unignore test which now passes

7 years agoDisable `cargo help -h`
Aleksey Kladov [Thu, 8 Mar 2018 19:35:42 +0000 (22:35 +0300)]
Disable `cargo help -h`

7 years agoFix verify-project command
Aleksey Kladov [Thu, 8 Mar 2018 19:33:10 +0000 (22:33 +0300)]
Fix verify-project command

7 years agoSupport built-in aliases
Aleksey Kladov [Thu, 8 Mar 2018 19:28:58 +0000 (22:28 +0300)]
Support built-in aliases

7 years agoSupport external subcommands
Aleksey Kladov [Thu, 8 Mar 2018 19:24:16 +0000 (22:24 +0300)]
Support external subcommands

7 years agoCleanup
Aleksey Kladov [Thu, 8 Mar 2018 19:15:07 +0000 (22:15 +0300)]
Cleanup

7 years agoRestore global initialization
Aleksey Kladov [Thu, 8 Mar 2018 19:06:02 +0000 (22:06 +0300)]
Restore global initialization

7 years agoUse exit code 1 for command line parsing errors
Aleksey Kladov [Thu, 8 Mar 2018 18:55:12 +0000 (21:55 +0300)]
Use exit code 1 for command line parsing errors

Note that while we use 101 in majority of cases, sometimes we use 1 as
well.

7 years agoFix some trivially fixable tests
Aleksey Kladov [Thu, 8 Mar 2018 18:48:38 +0000 (21:48 +0300)]
Fix some trivially fixable tests

7 years agoDrop old commands
Aleksey Kladov [Thu, 8 Mar 2018 18:27:51 +0000 (21:27 +0300)]
Drop old commands

7 years agoMove the rest of the commands to clap
Aleksey Kladov [Thu, 8 Mar 2018 18:21:04 +0000 (21:21 +0300)]
Move the rest of the commands to clap

7 years agoMove uninstall to clap
Aleksey Kladov [Thu, 8 Mar 2018 14:10:28 +0000 (17:10 +0300)]
Move uninstall to clap

7 years agoMove test to clap
Aleksey Kladov [Thu, 8 Mar 2018 13:56:36 +0000 (16:56 +0300)]
Move test to clap

7 years agoMove search to clap
Aleksey Kladov [Thu, 8 Mar 2018 11:12:00 +0000 (14:12 +0300)]
Move search to clap

7 years agoDon't copy-paste index argument
Aleksey Kladov [Thu, 8 Mar 2018 10:31:21 +0000 (13:31 +0300)]
Don't copy-paste index argument

7 years agoDon't copy-paste package argument
Aleksey Kladov [Thu, 8 Mar 2018 10:26:01 +0000 (13:26 +0300)]
Don't copy-paste package argument

7 years agoMove rustdoc to clap
Aleksey Kladov [Thu, 8 Mar 2018 10:16:17 +0000 (13:16 +0300)]
Move rustdoc to clap

7 years agoMove rustc to clap
Aleksey Kladov [Thu, 8 Mar 2018 10:05:49 +0000 (13:05 +0300)]
Move rustc to clap

7 years agoMove run to clap
Aleksey Kladov [Thu, 8 Mar 2018 09:36:31 +0000 (12:36 +0300)]
Move run to clap

7 years agoMove read-manifest to clap
Aleksey Kladov [Thu, 8 Mar 2018 09:05:42 +0000 (12:05 +0300)]
Move read-manifest to clap

7 years agoMove publish to clap
Aleksey Kladov [Thu, 8 Mar 2018 08:49:31 +0000 (11:49 +0300)]
Move publish to clap

7 years agoMove pkgid to clap
Aleksey Kladov [Wed, 7 Mar 2018 15:02:36 +0000 (18:02 +0300)]
Move pkgid to clap

7 years agoMove package to clap
Aleksey Kladov [Wed, 7 Mar 2018 14:54:10 +0000 (17:54 +0300)]
Move package to clap

7 years agoMove owner to clap
Aleksey Kladov [Wed, 7 Mar 2018 14:40:33 +0000 (17:40 +0300)]
Move owner to clap

7 years agoMove new to clap
Aleksey Kladov [Wed, 7 Mar 2018 13:59:16 +0000 (16:59 +0300)]
Move new to clap

7 years agoMove metadata to clap
Aleksey Kladov [Wed, 7 Mar 2018 13:39:25 +0000 (16:39 +0300)]
Move metadata to clap

7 years agoMove login to clap
Aleksey Kladov [Wed, 7 Mar 2018 13:17:10 +0000 (16:17 +0300)]
Move login to clap

7 years agoMove locate-project to clap
Aleksey Kladov [Wed, 7 Mar 2018 11:42:39 +0000 (14:42 +0300)]
Move locate-project to clap

7 years agoMove install to clap
Aleksey Kladov [Wed, 7 Mar 2018 11:31:39 +0000 (14:31 +0300)]
Move install to clap

7 years agoSpecify frozen & locked for all commands simultaneously
Aleksey Kladov [Wed, 7 Mar 2018 10:02:35 +0000 (13:02 +0300)]
Specify frozen & locked for all commands simultaneously

7 years agoMove init to clap
Aleksey Kladov [Wed, 7 Mar 2018 09:53:59 +0000 (12:53 +0300)]
Move init to clap

7 years agoMove git-checkout to clap
Aleksey Kladov [Wed, 7 Mar 2018 08:50:05 +0000 (11:50 +0300)]
Move git-checkout to clap

7 years agoMove generate-lockfile to clap
Aleksey Kladov [Wed, 7 Mar 2018 08:35:17 +0000 (11:35 +0300)]
Move generate-lockfile to clap

7 years agoMove fetch to clap
Aleksey Kladov [Wed, 7 Mar 2018 08:32:10 +0000 (11:32 +0300)]
Move fetch to clap

7 years agoMove doc to clap
Aleksey Kladov [Wed, 7 Mar 2018 08:22:46 +0000 (11:22 +0300)]
Move doc to clap

7 years agoMove clean to clap
Aleksey Kladov [Wed, 7 Mar 2018 07:57:51 +0000 (10:57 +0300)]
Move clean to clap

7 years agoMove check to clap
Aleksey Kladov [Wed, 7 Mar 2018 07:10:45 +0000 (10:10 +0300)]
Move check to clap

7 years agoTemporarly ignore some tests
Aleksey Kladov [Wed, 7 Mar 2018 06:46:16 +0000 (09:46 +0300)]
Temporarly ignore some tests

7 years agoPort bench and build to clap
Aleksey Kladov [Tue, 6 Mar 2018 21:01:03 +0000 (00:01 +0300)]
Port bench and build to clap

7 years agoSwitch to exhaustive matches in tests.
Giles Cope [Thu, 8 Mar 2018 18:37:30 +0000 (18:37 +0000)]
Switch to exhaustive matches in tests.

7 years agoAuto merge of #5150 - Eh2406:more_interning, r=alexcrichton
bors [Thu, 8 Mar 2018 15:21:26 +0000 (15:21 +0000)]
Auto merge of #5150 - Eh2406:more_interning, r=alexcrichton

More interning

This is a small part of the unsuccessful last commit of #5121, this part removes `InternedString::new` from the innerest of loops.

This is mostly a resubmission of #5147, that I accidentally deleted while bors was testing. This one has new commits, so github will take the resubition.

7 years agointern links attribute
Eh2406 [Thu, 8 Mar 2018 04:20:17 +0000 (23:20 -0500)]
intern links attribute

7 years agoAuto merge of #5147 - Eh2406:restucture, r=alexcrichton
bors [Thu, 8 Mar 2018 04:02:02 +0000 (04:02 +0000)]
Auto merge of #5147 - Eh2406:restucture, r=alexcrichton

restructure `Activations` for better clone

This builds on the work in #5121 When we last met we had:
5000000 ticks in ~48 sec, 0r 104k ticks/sec
This small change brings us to:
5000000 ticks in ~21 sec, 0r 238k ticks/sec
Edit: sorry for the large diff only the last commit is new. The rest are from #5121

7 years agorestructure `Activations` for better clone
Eh2406 [Wed, 7 Mar 2018 17:57:48 +0000 (12:57 -0500)]
restructure `Activations` for better clone