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

Optimize #1267

Open
wants to merge 88 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
4f29034
Optimize get_process_steps
dullbananas Mar 27, 2023
8ac82f2
Use Vec::with_capacity in check_wasm_pack_lastet_version
dullbananas Mar 28, 2023
08a66e6
Use &'static str for local version
dullbananas Mar 28, 2023
9d37592
Optimize version check
dullbananas Apr 1, 2023
85586ee
Reduce conversions from OsString to String
dullbananas Apr 2, 2023
114d12b
Reduce heap allocations
dullbananas Apr 3, 2023
ade563a
Add benchmark
dullbananas Apr 4, 2023
dd71328
increase warm up time
dullbananas Apr 4, 2023
87e0e26
Allow unused
dullbananas Apr 4, 2023
b5f7654
More optimization
dullbananas Apr 7, 2023
0dc955d
Optimize rustc version check
dullbananas Apr 8, 2023
cca671c
Clippy
dullbananas Apr 8, 2023
3f35b47
More optimization
dullbananas Apr 8, 2023
836fe7d
Add perf feature
dullbananas Apr 8, 2023
130e237
Refactor run_step
dullbananas Apr 8, 2023
4d90f54
Optimize lockfile
dullbananas Apr 8, 2023
0725710
Use iai benchmark
dullbananas Apr 8, 2023
204b138
Fix bench
dullbananas Apr 9, 2023
2db60b3
Add more benchmarks
dullbananas Apr 9, 2023
c6f1b56
Stuff
dullbananas Apr 9, 2023
1b6f23f
Clippy
dullbananas Apr 9, 2023
f74de45
Optimize initialization
dullbananas Apr 9, 2023
afc9ed2
Add Tool::name
dullbananas Apr 9, 2023
d328240
Use Command::args
dullbananas Apr 10, 2023
3a96012
Make installation check 47% faster with multithreading
dullbananas Apr 10, 2023
1c7700a
Optimize string conversion
dullbananas Apr 10, 2023
8fe5017
Optimize handling of unused cargo.toml fields
dullbananas Apr 16, 2023
4549771
Clippy
dullbananas Apr 16, 2023
c9bce17
Return Cow from find_pkg_directory
dullbananas Apr 16, 2023
1fe302c
Revert "Return Cow from find_pkg_directory"
dullbananas Jun 2, 2023
31cb1f0
Revert "Clippy"
dullbananas Jun 2, 2023
d7d3840
Revert "Optimize handling of unused cargo.toml fields"
dullbananas Jun 2, 2023
34eebb2
Revert "Optimize string conversion"
dullbananas Jun 2, 2023
220f20a
Revert "Make installation check 47% faster with multithreading"
dullbananas Jun 2, 2023
dbefd7c
Revert "Use Command::args"
dullbananas Jun 2, 2023
7b568da
Revert "Add Tool::name"
dullbananas Jun 2, 2023
a89c6e8
Revert "Optimize initialization"
dullbananas Jun 2, 2023
c83991c
Revert "Clippy"
dullbananas Jun 2, 2023
a58356a
Revert "Stuff"
dullbananas Jun 2, 2023
3b49bfb
Revert "Add more benchmarks"
dullbananas Jun 2, 2023
d8f2bdd
Revert "Fix bench"
dullbananas Jun 2, 2023
4670669
Revert "Use iai benchmark"
dullbananas Jun 2, 2023
32e39b2
Revert "Optimize lockfile"
dullbananas Jun 2, 2023
d61822b
Revert "Refactor run_step"
dullbananas Jun 2, 2023
4bf43c4
Revert "Add perf feature"
dullbananas Jun 2, 2023
4de8b27
Revert "More optimization"
dullbananas Jun 2, 2023
00d0ed0
Revert "Clippy"
dullbananas Jun 2, 2023
973c808
Revert "Optimize rustc version check"
dullbananas Jun 2, 2023
05f31ee
Revert "More optimization"
dullbananas Jun 2, 2023
c294980
Revert "Allow unused"
dullbananas Jun 2, 2023
1dd7e78
Revert "increase warm up time"
dullbananas Jun 2, 2023
259dcda
Revert "Add benchmark"
dullbananas Jun 2, 2023
6043c9c
Revert "Reduce heap allocations"
dullbananas Jun 2, 2023
4fc118b
Revert "Reduce conversions from OsString to String"
dullbananas Jun 2, 2023
9ad11fd
Revert "Optimize version check"
dullbananas Jun 2, 2023
1f3b2a4
Revert "Use &'static str for local version"
dullbananas Jun 2, 2023
25e638d
Revert "Use Vec::with_capacity in check_wasm_pack_lastet_version"
dullbananas Jun 2, 2023
e9b96c9
Revert "Optimize get_process_steps"
dullbananas Jun 2, 2023
5ed43d7
Merge branch 'rustwasm:master' into master
dullbananas Jun 2, 2023
8376336
Multithreaded checks
dullbananas Jun 2, 2023
86fd962
Optimize lockfile
dullbananas Jun 2, 2023
b6d095c
Add dhat heap profiler
dullbananas Jun 3, 2023
32c6248
Add FixtureBuilder for parallel file writes
dullbananas Jun 4, 2023
d692fc7
Refactor lockfile name filtering
dullbananas Jun 5, 2023
592be5b
Use Command::args with slices (partial)
dullbananas Jun 5, 2023
04fb5a1
Revert "Use Command::args with slices (partial)"
dullbananas Jun 5, 2023
31751f8
Use Command::args with arrays
dullbananas Jun 6, 2023
db8ba8e
Remove rust file
dullbananas Jun 6, 2023
a5d1e8e
Revert "Remove rust file"
dullbananas Jun 7, 2023
45dc394
Revert "Revert "Remove rust file""
dullbananas Jun 7, 2023
7f39506
Add args directly in npm_login
dullbananas Jun 7, 2023
eaf3430
Use trim_backtraces(None)
dullbananas Jun 7, 2023
6d56036
Optimize usage of cargo_metadata (removes most memory usage)
dullbananas Jun 7, 2023
01d0912
Avoid running `which` if wasm target is found
dullbananas Jun 7, 2023
dc9e99c
Optimize lockfile
dullbananas Jun 7, 2023
0692377
Replace structopt with clap (allocations increased)
dullbananas Jun 8, 2023
ba4c902
Revert "Use Command::args with arrays"
dullbananas Jun 9, 2023
6440129
Run step_check_crate_config in main thread
dullbananas Jun 9, 2023
845638b
Avoid calls to serde_ignored callback
dullbananas Jun 9, 2023
28ff353
Merge remote-tracking branch 'upstream/master'
dullbananas Jun 9, 2023
7cd74e9
Move FixtureBuilder::new to Fixture::new
dullbananas Jun 9, 2023
07ab317
Revert "Replace structopt with clap (allocations increased)"
dullbananas Jun 17, 2023
9fa1f80
Refactor
dullbananas Jun 17, 2023
13e3c63
Revert "Move FixtureBuilder::new to Fixture::new"
dullbananas Jun 17, 2023
cf4961a
Revert "Add FixtureBuilder for parallel file writes"
dullbananas Jun 17, 2023
59e707a
Merge branch 'master' into master
dullbananas Jun 17, 2023
d493270
Reduce use statement diff
dullbananas Jun 17, 2023
406ef37
Fix my botched merge conflict resolution
dullbananas Jun 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ tests/bin
/build-installer
docs/book
docs/installer
dhat-*.json

.idea
49 changes: 49 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ binary-install = "0.1.0"
cargo_metadata = "0.15.2"
chrono = "0.4.23"
console = "0.15.5"
dhat = { version = "0.3.2", optional = true }
dialoguer = "0.10.3"
env_logger = { version = "0.10.0", default-features = false }
glob = "0.3.1"
Expand All @@ -43,3 +44,5 @@ predicates = "3.0.3"
serial_test = "2.0.0"
tempfile = "3.3.0"

[features]
dhat-heap = ["dep:dhat"]
39 changes: 14 additions & 25 deletions src/build/wasm_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ pub fn check_for_wasm32_target() -> Result<()> {
PBAR.info(&msg);

// Check if wasm32 target is present, otherwise bail.
match check_wasm32_target() {
Ok(ref wasm32_check) if wasm32_check.found => Ok(()),
Ok(wasm32_check) => bail!("{}", wasm32_check),
Err(err) => Err(err),
}
check_wasm32_target()
}

/// Get rustc's sysroot as a PathBuf
Expand Down Expand Up @@ -97,36 +93,29 @@ fn is_wasm32_target_in_sysroot(sysroot: &Path) -> bool {
}
}

fn check_wasm32_target() -> Result<Wasm32Check> {
fn check_wasm32_target() -> Result<()> {
let sysroot = get_rustc_sysroot()?;
let rustc_path = which::which("rustc")?;

// If wasm32-unknown-unknown already exists we're ok.
if is_wasm32_target_in_sysroot(&sysroot) {
Ok(Wasm32Check {
rustc_path,
sysroot,
found: true,
is_rustup: false,
})
Ok(())
// If it doesn't exist, then we need to check if we're using rustup.
} else {
let rustc_path = which::which("rustc")?;
// If sysroot contains "rustup", then we can assume we're using rustup
// and use rustup to add the wasm32-unknown-unknown target.
if sysroot.to_string_lossy().contains("rustup") {
rustup_add_wasm_target().map(|()| Wasm32Check {
rustc_path,
sysroot,
found: true,
is_rustup: true,
})
rustup_add_wasm_target()
} else {
Ok(Wasm32Check {
rustc_path,
sysroot,
found: false,
is_rustup: false,
})
bail!(
"{}",
Wasm32Check {
rustc_path,
sysroot,
found: false,
is_rustup: false,
}
);
}
}
}
Expand Down
28 changes: 18 additions & 10 deletions src/command/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::command::utils::{create_pkg_dir, get_crate_path};
use crate::emoji;
use crate::install::{self, InstallMode, Tool};
use crate::license;
use crate::lockfile::Lockfile;
use crate::lockfile;
use crate::manifest;
use crate::readme;
use crate::wasm_opt;
Expand Down Expand Up @@ -289,11 +289,7 @@ impl Build {
match &mode {
InstallMode::Force => {}
_ => {
steps.extend(steps![
step_check_rustc_version,
step_check_crate_config,
step_check_for_wasm_target,
]);
steps.extend(steps![step_check_rustc, step_check_crate_config,]);
}
}

Expand All @@ -316,7 +312,19 @@ impl Build {
steps
}

fn step_check_rustc_version(&mut self) -> Result<()> {
fn step_check_rustc(&mut self) -> Result<()> {
std::thread::scope(|s| {
for handle in [
s.spawn(|| self.step_check_rustc_version()),
s.spawn(|| self.step_check_for_wasm_target()),
] {
handle.join().unwrap()?;
}
Ok(())
})
}

fn step_check_rustc_version(&self) -> Result<()> {
info!("Checking rustc version...");
let version = build::check_rustc_version()?;
let msg = format!("rustc version is {}.", version);
Expand All @@ -331,7 +339,7 @@ impl Build {
Ok(())
}

fn step_check_for_wasm_target(&mut self) -> Result<()> {
fn step_check_for_wasm_target(&self) -> Result<()> {
info!("Checking for wasm-target...");
build::wasm_target::check_for_wasm32_target()?;
info!("Checking for wasm-target was successful.");
Expand Down Expand Up @@ -390,8 +398,8 @@ impl Build {

fn step_install_wasm_bindgen(&mut self) -> Result<()> {
info!("Identifying wasm-bindgen dependency...");
let lockfile = Lockfile::new(&self.crate_data)?;
let bindgen_version = lockfile.require_wasm_bindgen()?;
let [package] = lockfile::Package::get(&self.crate_data, ["wasm-bindgen"])?;
let bindgen_version = package.require_version_or_suggest("dependencies", "0.2")?;
info!("Installing wasm-bindgen-cli...");
let bindgen = install::download_prebuilt_or_cargo_install(
Tool::WasmBindgen,
Expand Down
16 changes: 5 additions & 11 deletions src/command/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::build;
use crate::cache;
use crate::command::utils::get_crate_path;
use crate::install::{self, InstallMode, Tool};
use crate::lockfile::Lockfile;
use crate::lockfile;
use crate::manifest;
use crate::test::{self, webdriver};
use anyhow::{bail, Result};
Expand Down Expand Up @@ -276,22 +276,16 @@ impl Test {

fn step_install_wasm_bindgen(&mut self) -> Result<()> {
info!("Identifying wasm-bindgen dependency...");
let lockfile = Lockfile::new(&self.crate_data)?;
let bindgen_version = lockfile.require_wasm_bindgen()?;
let [bindgen, bindgen_test] =
lockfile::Package::get(&self.crate_data, ["wasm-bindgen", "wasm-bindgen-test"])?;
let bindgen_version = bindgen.require_version_or_suggest("dependencies", "0.2")?;

// Unlike `wasm-bindgen` and `wasm-bindgen-cli`, `wasm-bindgen-test`
// will work with any semver compatible `wasm-bindgen-cli`, so just make
// sure that it is depended upon, so we can run tests on
// `wasm32-unkown-unknown`. Don't enforce that it is the same version as
// `wasm-bindgen`.
if lockfile.wasm_bindgen_test_version().is_none() {
bail!(
"Ensure that you have \"{}\" as a dependency in your Cargo.toml file:\n\
[dev-dependencies]\n\
wasm-bindgen-test = \"0.2\"",
style("wasm-bindgen-test").bold().dim(),
)
}
bindgen_test.require_version_or_suggest("dev-dependencies", "0.2")?;

let status = install::download_prebuilt_or_cargo_install(
Tool::WasmBindgen,
Expand Down
Loading