Commit graph

480 commits

Author SHA1 Message Date
Jiahao XU
b2d09e2b13
Rm unused derive(Clone) for DesiredTargets
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 15:07:09 +10:00
Jiahao XU
eda7b9445a
Rm unnecessary Arc inside DesiredTargetsInner
Since `DesiredTargets` is now stored in `binstall::Options`, which
itself is wrapped in an `Arc`, `DesiredTargetsInner::Initialized` no
longer needs an `Arc` for O(1) `clone`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 15:06:00 +10:00
Jiahao XU
6a95bb07e0
Add field desired_targets to binstall::Options
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 15:05:12 +10:00
Jiahao XU
aa88dce215
Add field cli_overrides to binstall::Options
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 15:00:01 +10:00
Jiahao XU
f09004b5b7
Optimize: Share crates_io_api::AsyncClient
So that the connection pool and the rate limit will be shared.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 14:50:51 +10:00
Jiahao XU
21eac33e1f
Optimize: Create new fn helpers::cargo_home
that caches return value of `home::cargo_home`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 13:13:07 +10:00
Jiahao XU
305a4e4c30
Improve err msg in MultiFetcher::first_available
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 13:07:20 +10:00
Jiahao XU
dc8d8ccd88
Optimize MultiFetcher: Start checking ASAP
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 13:06:34 +10:00
Jiahao XU
6180e9ec3e
Add comment in fn resolve
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 13:00:58 +10:00
Jiahao XU
c418c2dbbe
Optimize arg parsing: Avoid O(n) Vec::remove
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 12:44:54 +10:00
Jiahao XU
cfe7703af9
Forbid --manifest-path to used with batch installation
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 19:11:02 +10:00
Jiahao XU
08190ac179
Add ManifestPathConflictedWithBatchInstallation
to error `BinstallError`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 19:09:59 +10:00
Jiahao XU
3981400ebb
Create new type LazyJobserverClient
and use it to replace `jobserver::Client`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 17:54:17 +10:00
Jiahao XU
a1d7a7c117
Refactor: Extract new mod jobserver_client.rs
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 17:37:23 +10:00
Jiahao XU
2490cd5a84
Refactor: Extract new mod binstall/install.rs
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 17:30:34 +10:00
Jiahao XU
5e35604012
Refactor: Extract new mod binstall/resolve.rs
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 17:28:53 +10:00
Jiahao XU
921774b8f9
Refactor: Extract new mod binstall
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 17:26:24 +10:00
Jiahao XU
3b82e9e375
Rm unnecessary clone in install_from_package
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 17:04:26 +10:00
Jiahao XU
1eedae1ee2
Rm unused param temp_dir from install_from_package
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 16:59:23 +10:00
Jiahao XU
1ebd4bdb75
Refactor: Reduce params of install_from_package
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 16:58:12 +10:00
Jiahao XU
5bdffd9178
Refactor: Impl Source::cratesio_registry
Makes initializing `metafiles::CrateVersionSource` more readable and
improves performance since the parsing is now cached.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 16:48:34 +10:00
Jiahao XU
67ca36a0b5
Fix jobserver_client: Create it as early as possible
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-19 12:15:00 +10:00
Jiahao XU
2bf7640729
Optimize: Avoid double spawn if no_confirm
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-19 12:06:16 +10:00
Jiahao XU
de7ecad32c
Optimize: Avoid creation of Arc<str> for target
in `entry`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-19 12:02:09 +10:00
Jiahao XU
758dab7d4f
Optimize DesiredTargets: Avoid mem alloc on clone
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-19 11:59:10 +10:00
Jiahao XU
b026462018
Refactor: Simplify struct Resolution
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-19 00:43:17 +10:00
Jiahao XU
c6281d8ea0
Fix opts.no_cleanup behavior
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-19 00:39:27 +10:00
Jiahao XU
b223990bb1
Simplify helpers::await_task API
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-19 00:35:48 +10:00
Jiahao XU
072253ebae
Improve comment in create_jobserver_client
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-19 00:32:56 +10:00
Jiahao XU
fb0a6a5514
Use jobserver to limit parallism of cargo-install
Since we execute multiple `cargo-install` concurrently, we must use
jobserver to limit the parallism so that they won't spawn too much
processes/threads to overload the system.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 21:12:58 +10:00
Jiahao XU
c67c59b3ca
Impl new fn helpers::create_jobserver_client
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 21:04:36 +10:00
Jiahao XU
9552e0e8ed
Add comment to entry to improve readbility
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 17:31:29 +10:00
Jiahao XU
79ec122647
Refactor entry: Avoid Arc::clone
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 17:26:16 +10:00
Jiahao XU
119192f8ee
Refactor main.rs: Print resolution in resolve
This simplified `entry`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 17:21:35 +10:00
Jiahao XU
bcb46cd736
Optimize main.rs: Avoid frequent Box::clone
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 17:17:56 +10:00
Jiahao XU
c66d8154eb
Print out resolution in optimized path
where confirmation isn't required.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 17:13:06 +10:00
Jiahao XU
f0fb7da99b
Refactor main.rs: Extract fn Resolution::print
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 17:11:27 +10:00
Jiahao XU
90059c11cf
Optimize: Launch install immediately if confirmation is not required
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 17:09:29 +10:00
Jiahao XU
8ca85382af
Refactor: Avoid repeated heap alloc of temp_dir
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 17:00:18 +10:00
Jiahao XU
d514219ee4
Refactor main.rs: Extract new fn install
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 16:58:04 +10:00
Jiahao XU
40a872dbe3
Avoid Box::clone for targets
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 16:54:45 +10:00
Jiahao XU
7f11b74f5e
Support new feature batch installation!
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 16:46:51 +10:00
Jiahao XU
5e7aab7373
Impl helpers::await_task: Handle JoinError
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 16:46:21 +10:00
Jiahao XU
730f7d6c15
Refactor main.rs: Simplify install_from_source
Rm arg `opts`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 16:21:03 +10:00
Jiahao XU
d6db552db1
Refactor main.rs: Extract new fn resolve
prepare for the new feature batch installation.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 16:16:50 +10:00
Jiahao XU
409f31f0bf
derive(Clone) for CrateName
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 16:07:47 +10:00
Jiahao XU
9e1f873bb5
derive(Clone) for DesiredTargets
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-18 16:05:37 +10:00
Jiahao XU
aecc474f29
Rm unused BinstallError::VersionWarning
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-12 18:34:20 +10:00
Jiahao XU
c87941211c
Treat 1.2.3 as =1.2.3 to match cargo-install
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-12 18:33:31 +10:00
Jiahao XU
e2207f7b59
Add diagnostic(help) to DuplicateVersionReq
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-12 17:12:01 +10:00