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

Rollup of 6 pull requests #71934

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8f5c66c
Introduce BTreeMap benches of iter itself
ssomers Apr 23, 2020
8730227
Speed up BTreeMap iteration by intertwined descend to the initial lea…
ssomers Apr 22, 2020
19e5da9
SipHasher::new() is literally with SipHasher with both keys being 0
hbina May 1, 2020
9bcf409
x.py: Give a more helpful error message if curl isn't installed
jyn514 May 3, 2020
75f066d
Handle binop on unbound type param
estebank Apr 7, 2020
1473a66
Suggest restricting type param when it doesn't satisfy projection
estebank Apr 7, 2020
3453db7
review comments: use or-pattern
estebank Apr 7, 2020
d8d02f8
On incorrect equality constraint likely to be assoc type, suggest app…
estebank Apr 8, 2020
c93c660
review comments and rebase fix
estebank Apr 17, 2020
5d64e91
review comment: use `body_id`
estebank Apr 19, 2020
61fdd3e
expand comment on default mutex behavior
RalfJung May 4, 2020
40a6b8c
explain our rwlock implementation (and fix a potential data race)
RalfJung May 4, 2020
b13f234
fix rebase
estebank May 4, 2020
b17b20c
Add docstring to `deny_equality_constraints`
estebank May 4, 2020
3f50292
edit Mutex comment
RalfJung May 4, 2020
b83853d
Add command aliases from Cargo to x.py commands
mibac138 May 4, 2020
f9866f9
rely on rdlock/wrlock not returning anything but the specified error …
RalfJung May 5, 2020
793f921
Rollup merge of #70908 - estebank:suggest-add, r=nikomatsakis
Dylan-DPC May 5, 2020
d329f74
Rollup merge of #71510 - ssomers:btreemap_iter_intertwined, r=Mark-Si…
Dylan-DPC May 5, 2020
61ac8a1
Rollup merge of #71727 - hbina:simplified_usage, r=Mark-Simulacrum
Dylan-DPC May 5, 2020
1ed91a2
Rollup merge of #71819 - jyn514:check-for-tools, r=Mark-Simulacrum
Dylan-DPC May 5, 2020
c879b32
Rollup merge of #71889 - RalfJung:rwlock, r=Amanieu
Dylan-DPC May 5, 2020
bd89441
Rollup merge of #71905 - mibac138:x-cmd-alias, r=Mark-Simulacrum
Dylan-DPC May 5, 2020
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
48 changes: 25 additions & 23 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def _download(path, url, probably_big, verbose, exception):
option = "-#"
else:
option = "-s"
require(["curl", "--version"])
run(["curl", option,
"-y", "30", "-Y", "10", # timeout if speed is < 10 bytes/sec for > 30 seconds
"--connect-timeout", "30", # timeout if cannot connect within 30 seconds
Expand Down Expand Up @@ -143,6 +144,21 @@ def run(args, verbose=False, exception=False, **kwargs):
sys.exit(err)


def require(cmd, exit=True):
'''Run a command, returning its output.
On error,
If `exit` is `True`, exit the process.
Otherwise, return None.'''
try:
return subprocess.check_output(cmd).strip()
except (subprocess.CalledProcessError, OSError) as exc:
if not exit:
return None
print("error: unable to run `{}`: {}".format(' '.join(cmd), exc))
print("Please make sure it's installed and in the path.")
sys.exit(1)


def stage0_data(rust_root):
"""Build a dictionary from stage0.txt"""
nightlies = os.path.join(rust_root, "src/stage0.txt")
Expand All @@ -164,16 +180,12 @@ def format_build_time(duration):
def default_build_triple():
"""Build triple as in LLVM"""
default_encoding = sys.getdefaultencoding()
try:
ostype = subprocess.check_output(
['uname', '-s']).strip().decode(default_encoding)
cputype = subprocess.check_output(
['uname', '-m']).strip().decode(default_encoding)
except (subprocess.CalledProcessError, OSError):
if sys.platform == 'win32':
return 'x86_64-pc-windows-msvc'
err = "uname not found"
sys.exit(err)
required = not sys.platform == 'win32'
ostype = require(["uname", "-s"], exit=required).decode(default_encoding)
cputype = require(['uname', '-m'], exit=required).decode(default_encoding)

if ostype is None or cputype is None:
return 'x86_64-pc-windows-msvc'

# The goal here is to come up with the same triple as LLVM would,
# at least for the subset of platforms we're willing to target.
Expand Down Expand Up @@ -203,12 +215,7 @@ def default_build_triple():
# output from that option is too generic for our purposes (it will
# always emit 'i386' on x86/amd64 systems). As such, isainfo -k
# must be used instead.
try:
cputype = subprocess.check_output(
['isainfo', '-k']).strip().decode(default_encoding)
except (subprocess.CalledProcessError, OSError):
err = "isainfo not found"
sys.exit(err)
cputype = require(['isainfo', '-k']).decode(default_encoding)
elif ostype.startswith('MINGW'):
# msys' `uname` does not print gcc configuration, but prints msys
# configuration. so we cannot believe `uname -m`:
Expand Down Expand Up @@ -766,13 +773,8 @@ def update_submodules(self):
default_encoding = sys.getdefaultencoding()

# check the existence and version of 'git' command
try:
git_version_output = subprocess.check_output(['git', '--version'])
git_version_str = git_version_output.strip().split()[2].decode(default_encoding)
self.git_version = distutils.version.LooseVersion(git_version_str)
except (subprocess.CalledProcessError, OSError):
print("error: `git` is not found, please make sure it's installed and in the path.")
sys.exit(1)
git_version_str = require(['git', '--version']).split()[2].decode(default_encoding)
self.git_version = distutils.version.LooseVersion(git_version_str)

slow_submodules = self.get_toml('fast-submodules') == "false"
start_time = time()
Expand Down
30 changes: 17 additions & 13 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,18 @@ impl Flags {
Usage: x.py <subcommand> [options] [<paths>...]

Subcommands:
build Compile either the compiler or libraries
check Compile either the compiler or libraries, using cargo check
build, b Compile either the compiler or libraries
check, c Compile either the compiler or libraries, using cargo check
clippy Run clippy (uses rustup/cargo-installed clippy binary)
fix Run cargo fix
fmt Run rustfmt
test Build and run some test suites
test, t Build and run some test suites
bench Build and run some benchmarks
doc Build documentation
clean Clean out build directories
dist Build distribution artifacts
install Install distribution artifacts
run Run tools contained in this repository
run, r Run tools contained in this repository

To learn more about a subcommand, run `./x.py <subcommand> -h`",
);
Expand Down Expand Up @@ -184,17 +184,21 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
// there on out.
let subcommand = args.iter().find(|&s| {
(s == "build")
|| (s == "b")
|| (s == "check")
|| (s == "c")
|| (s == "clippy")
|| (s == "fix")
|| (s == "fmt")
|| (s == "test")
|| (s == "t")
|| (s == "bench")
|| (s == "doc")
|| (s == "clean")
|| (s == "dist")
|| (s == "install")
|| (s == "run")
|| (s == "r")
});
let subcommand = match subcommand {
Some(s) => s,
Expand All @@ -210,7 +214,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",

// Some subcommands get extra options
match subcommand.as_str() {
"test" => {
"test" | "t" => {
opts.optflag("", "no-fail-fast", "Run all tests regardless of failure");
opts.optmulti("", "test-args", "extra arguments", "ARGS");
opts.optmulti(
Expand Down Expand Up @@ -285,7 +289,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
}
// Extra help text for some commands
match subcommand.as_str() {
"build" => {
"build" | "b" => {
subcommand_help.push_str(
"\n
Arguments:
Expand All @@ -312,7 +316,7 @@ Arguments:
Once this is done, build/$ARCH/stage1 contains a usable compiler.",
);
}
"check" => {
"check" | "c" => {
subcommand_help.push_str(
"\n
Arguments:
Expand Down Expand Up @@ -362,7 +366,7 @@ Arguments:
./x.py fmt --check",
);
}
"test" => {
"test" | "t" => {
subcommand_help.push_str(
"\n
Arguments:
Expand Down Expand Up @@ -407,7 +411,7 @@ Arguments:
./x.py doc --stage 1",
);
}
"run" => {
"run" | "r" => {
subcommand_help.push_str(
"\n
Arguments:
Expand Down Expand Up @@ -453,11 +457,11 @@ Arguments:
}

let cmd = match subcommand.as_str() {
"build" => Subcommand::Build { paths },
"check" => Subcommand::Check { paths },
"build" | "b" => Subcommand::Build { paths },
"check" | "c" => Subcommand::Check { paths },
"clippy" => Subcommand::Clippy { paths },
"fix" => Subcommand::Fix { paths },
"test" => Subcommand::Test {
"test" | "t" => Subcommand::Test {
paths,
bless: matches.opt_present("bless"),
compare_mode: matches.opt_str("compare-mode"),
Expand Down Expand Up @@ -487,7 +491,7 @@ Arguments:
"fmt" => Subcommand::Format { check: matches.opt_present("check") },
"dist" => Subcommand::Dist { paths },
"install" => Subcommand::Install { paths },
"run" => {
"run" | "r" => {
if paths.is_empty() {
println!("\nrun requires at least a path!\n");
usage(1, &opts, &subcommand_help, &extra_help);
Expand Down
118 changes: 72 additions & 46 deletions src/liballoc/benches/btree/map.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::BTreeMap;
use std::iter::Iterator;
use std::ops::Bound::{Excluded, Unbounded};
use std::ops::RangeBounds;
use std::vec::Vec;

use rand::{seq::SliceRandom, thread_rng, Rng};
Expand Down Expand Up @@ -117,7 +117,7 @@ map_find_rand_bench! {find_rand_10_000, 10_000, BTreeMap}
map_find_seq_bench! {find_seq_100, 100, BTreeMap}
map_find_seq_bench! {find_seq_10_000, 10_000, BTreeMap}

fn bench_iter(b: &mut Bencher, size: i32) {
fn bench_iteration(b: &mut Bencher, size: i32) {
let mut map = BTreeMap::<i32, i32>::new();
let mut rng = thread_rng();

Expand All @@ -133,21 +133,21 @@ fn bench_iter(b: &mut Bencher, size: i32) {
}

#[bench]
pub fn iter_20(b: &mut Bencher) {
bench_iter(b, 20);
pub fn iteration_20(b: &mut Bencher) {
bench_iteration(b, 20);
}

#[bench]
pub fn iter_1000(b: &mut Bencher) {
bench_iter(b, 1000);
pub fn iteration_1000(b: &mut Bencher) {
bench_iteration(b, 1000);
}

#[bench]
pub fn iter_100000(b: &mut Bencher) {
bench_iter(b, 100000);
pub fn iteration_100000(b: &mut Bencher) {
bench_iteration(b, 100000);
}

fn bench_iter_mut(b: &mut Bencher, size: i32) {
fn bench_iteration_mut(b: &mut Bencher, size: i32) {
let mut map = BTreeMap::<i32, i32>::new();
let mut rng = thread_rng();

Expand All @@ -163,18 +163,18 @@ fn bench_iter_mut(b: &mut Bencher, size: i32) {
}

#[bench]
pub fn iter_mut_20(b: &mut Bencher) {
bench_iter_mut(b, 20);
pub fn iteration_mut_20(b: &mut Bencher) {
bench_iteration_mut(b, 20);
}

#[bench]
pub fn iter_mut_1000(b: &mut Bencher) {
bench_iter_mut(b, 1000);
pub fn iteration_mut_1000(b: &mut Bencher) {
bench_iteration_mut(b, 1000);
}

#[bench]
pub fn iter_mut_100000(b: &mut Bencher) {
bench_iter_mut(b, 100000);
pub fn iteration_mut_100000(b: &mut Bencher) {
bench_iteration_mut(b, 100000);
}

fn bench_first_and_last(b: &mut Bencher, size: i32) {
Expand Down Expand Up @@ -202,57 +202,83 @@ pub fn first_and_last_10k(b: &mut Bencher) {
bench_first_and_last(b, 10_000);
}

#[bench]
pub fn range_excluded_excluded(b: &mut Bencher) {
let size = 144;
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
const BENCH_RANGE_SIZE: i32 = 145;
const BENCH_RANGE_COUNT: i32 = BENCH_RANGE_SIZE * (BENCH_RANGE_SIZE - 1) / 2;

fn bench_range<F, R>(b: &mut Bencher, f: F)
where
F: Fn(i32, i32) -> R,
R: RangeBounds<i32>,
{
let map: BTreeMap<_, _> = (0..BENCH_RANGE_SIZE).map(|i| (i, i)).collect();
b.iter(|| {
for first in 0..size {
for last in first + 1..size {
black_box(map.range((Excluded(first), Excluded(last))));
let mut c = 0;
for i in 0..BENCH_RANGE_SIZE {
for j in i + 1..BENCH_RANGE_SIZE {
black_box(map.range(f(i, j)));
c += 1;
}
}
debug_assert_eq!(c, BENCH_RANGE_COUNT);
});
}

#[bench]
pub fn range_excluded_unbounded(b: &mut Bencher) {
let size = 144;
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
b.iter(|| {
for first in 0..size {
black_box(map.range((Excluded(first), Unbounded)));
}
});
pub fn range_included_excluded(b: &mut Bencher) {
bench_range(b, |i, j| i..j);
}

#[bench]
pub fn range_included_included(b: &mut Bencher) {
let size = 144;
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
b.iter(|| {
for first in 0..size {
for last in first..size {
black_box(map.range(first..=last));
}
}
});
bench_range(b, |i, j| i..=j);
}

#[bench]
pub fn range_included_unbounded(b: &mut Bencher) {
let size = 144;
bench_range(b, |i, _| i..);
}

#[bench]
pub fn range_unbounded_unbounded(b: &mut Bencher) {
bench_range(b, |_, _| ..);
}

fn bench_iter(b: &mut Bencher, repeats: i32, size: i32) {
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
b.iter(|| {
for first in 0..size {
black_box(map.range(first..));
for _ in 0..repeats {
black_box(map.iter());
}
});
}

/// Contrast range_unbounded_unbounded with `iter()`.
#[bench]
pub fn range_unbounded_unbounded(b: &mut Bencher) {
let size = 144;
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
b.iter(|| map.range(..));
pub fn range_unbounded_vs_iter(b: &mut Bencher) {
bench_iter(b, BENCH_RANGE_COUNT, BENCH_RANGE_SIZE);
}

#[bench]
pub fn iter_0(b: &mut Bencher) {
bench_iter(b, 1_000, 0);
}

#[bench]
pub fn iter_1(b: &mut Bencher) {
bench_iter(b, 1_000, 1);
}

#[bench]
pub fn iter_100(b: &mut Bencher) {
bench_iter(b, 1_000, 100);
}

#[bench]
pub fn iter_10k(b: &mut Bencher) {
bench_iter(b, 1_000, 10_000);
}

#[bench]
pub fn iter_1m(b: &mut Bencher) {
bench_iter(b, 1_000, 1_000_000);
}
Loading