Skip to content

Commit bbce846

Browse files
Merge pull request #233 from Mark-Simulacrum/add-benchmarks
Add Cargo, Webrender, Ripgrep
2 parents b297af0 + cd8e946 commit bbce846

File tree

1,190 files changed

+247272
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,190 files changed

+247272
-0
lines changed

collector/benchmarks/cargo/.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/target
2+
Cargo.lock
3+
.cargo
4+
/config.stamp
5+
/Makefile
6+
/config.mk
7+
src/doc/build
8+
src/etc/*.pyc
9+
src/registry/target
10+
rustc
11+
__pycache__
12+
.idea/
13+
*.iml
14+
*.swp
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
language: rust
2+
rust: stable
3+
sudo: required
4+
dist: trusty
5+
6+
git:
7+
depth: 1
8+
9+
# Using 'cache: cargo' to cache target/ and all of $HOME/.cargo/
10+
# doesn't work well: the cache is large and it takes several minutes
11+
# to move it to and from S3. So instead we only cache the mdbook
12+
# binary.
13+
cache:
14+
directories:
15+
- $HOME/.cargo/bin/
16+
17+
matrix:
18+
include:
19+
- env: TARGET=x86_64-unknown-linux-gnu
20+
ALT=i686-unknown-linux-gnu
21+
- env: TARGET=x86_64-apple-darwin
22+
ALT=i686-apple-darwin
23+
os: osx
24+
25+
- env: TARGET=x86_64-unknown-linux-gnu
26+
ALT=i686-unknown-linux-gnu
27+
rust: beta
28+
29+
- env: TARGET=x86_64-unknown-linux-gnu
30+
ALT=i686-unknown-linux-gnu
31+
rust: nightly
32+
install:
33+
- mdbook --help || cargo install mdbook --force
34+
script:
35+
- cargo test
36+
- cargo doc --no-deps
37+
- (cd src/doc && mdbook build --dest-dir ../../target/doc)
38+
39+
exclude:
40+
- rust: stable
41+
42+
before_script:
43+
- rustup target add $ALT
44+
script:
45+
- cargo test
46+
47+
notifications:
48+
email:
49+
on_success: never
50+
51+
addons:
52+
apt:
53+
packages:
54+
- gcc-multilib
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs
2+
index c7a0fdf..e37f73a 100644
3+
--- a/src/cargo/sources/path.rs
4+
+++ b/src/cargo/sources/path.rs
5+
@@ -55,6 +55,7 @@ impl<'cfg> PathSource<'cfg> {
6+
}
7+
8+
pub fn preload_with(&mut self, pkg: Package) {
9+
+ println!("testing");
10+
assert!(!self.updated);
11+
assert!(!self.recursive);
12+
assert!(self.packages.is_empty());
+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Cargo Architecture
2+
3+
This document gives a high level overview of Cargo internals. You may
4+
find it useful if you want to contribute to Cargo or if you are
5+
interested in the inner workings of Cargo.
6+
7+
8+
## Subcommands
9+
10+
Cargo is organized as a set of `clap` subcommands. All subcommands live in
11+
`src/bin/commands` directory. `src/bin/cargo.rs` is the entry point.
12+
13+
A typical subcommand, such as `src/bin/commands/build.rs`, parses command line
14+
options, reads the configuration files, discovers the Cargo project in
15+
the current directory and delegates the actual implementation to one
16+
of the functions in `src/cargo/ops/mod.rs`. This short file is a good
17+
place to find out about most of the things that Cargo can do.
18+
19+
20+
## Important Data Structures
21+
22+
There are some important data structures which are used throughout
23+
Cargo.
24+
25+
`Config` is available almost everywhere and holds "global"
26+
information, such as `CARGO_HOME` or configuration from
27+
`.cargo/config` files. The `shell` method of `Config` is the entry
28+
point for printing status messages and other info to the console.
29+
30+
`Workspace` is the description of the workspace for the current
31+
working directory. Each workspace contains at least one
32+
`Package`. Each package corresponds to a single `Cargo.toml`, and may
33+
define several `Target`s, such as the library, binaries, integration
34+
test or examples. Targets are crates (each target defines a crate
35+
root, like `src/lib.rs` or `examples/foo.rs`) and are what is actually
36+
compiled by `rustc`.
37+
38+
A typical package defines the single library target and several
39+
auxiliary ones. Packages are a unit of dependency in Cargo, and when
40+
package `foo` depends on package `bar`, that means that each target
41+
from `foo` needs the library target from `bar`.
42+
43+
`PackageId` is the unique identifier of a (possibly remote)
44+
package. It consist of three components: name, version and source
45+
id. Source is the place where the source code for package comes
46+
from. Typical sources are crates.io, a git repository or a folder on
47+
the local hard drive.
48+
49+
`Resolve` is the representation of a directed acyclic graph of package
50+
dependencies, which uses `PackageId`s for nodes. This is the data
51+
structure that is saved to the lock file. If there is no lockfile,
52+
Cargo constructs a resolve by finding a graph of packages which
53+
matches declared dependency specification according to semver.
54+
55+
56+
## Persistence
57+
58+
Cargo is a non-daemon command line application, which means that all
59+
the information used by Cargo must be persisted on the hard drive. The
60+
main sources of information are `Cargo.toml` and `Cargo.lock` files,
61+
`.cargo/config` configuration files and the globally shared registry
62+
of packages downloaded from crates.io, usually located at
63+
`~/.cargo/registry`. See `src/sources/registry` for the specifics of
64+
the registry storage format.
65+
66+
67+
## Concurrency
68+
69+
Cargo is mostly single threaded. The only concurrency inside a single
70+
instance of Cargo happens during compilation, when several instances
71+
of `rustc` are invoked in parallel to build independent
72+
targets. However there can be several different instances of Cargo
73+
process running concurrently on the system. Cargo guarantees that this
74+
is always safe by using file locks when accessing potentially shared
75+
data like the registry or the target directory.
76+
77+
78+
## Tests
79+
80+
Cargo has an impressive test suite located in the `tests` folder. Most
81+
of the test are integration: a project structure with `Cargo.toml` and
82+
rust source code is created in a temporary directory, `cargo` binary
83+
is invoked via `std::process::Command` and then stdout and stderr are
84+
verified against the expected output. To simplify testing, several
85+
macros of the form `[MACRO]` are used in the expected output. For
86+
example, `[..]` matches any string and `[/]` matches `/` on Unixes and
87+
`\` on windows.
88+
89+
To see stdout and stderr streams of the subordinate process, add `.stream()`
90+
call to `execs()`:
91+
92+
```rust
93+
// Before
94+
assert_that(
95+
p.cargo("run"),
96+
execs().with_status(0)
97+
);
98+
99+
// After
100+
assert_that(
101+
p.cargo("run"),
102+
execs().stream().with_status(0)
103+
);
104+
```
105+
106+
Alternatively to build and run a custom version of cargo simply run `cargo build`
107+
and execute `target/debug/cargo`. Note that `+nightly`/`+stable` (and variants),
108+
being [rustup](https://rustup.rs/) features, won't work when executing the locally
109+
built cargo binary directly, you have to instead build with `cargo +nightly build`
110+
and run with `rustup run` (e.g `rustup run nightly
111+
<path-to-cargo>/target/debug/cargo <args>..`) (or set the `RUSTC` env var to point
112+
to nightly rustc).
113+
114+
Because the test suite has `#![deny(warnings)]` at times you might find it
115+
convenient to override this with `RUSTFLAGS`, for example
116+
`RUSTFLAGS="--cap-lints warn" cargo build`.
117+
118+
## Logging
119+
120+
Cargo uses [`env_logger`](https://docs.rs/env_logger/*/env_logger/), so you can set
121+
`RUST_LOG` environment variable to get the logs. This is useful both for diagnosing
122+
bugs in stable Cargo and for local development. Cargo also has internal hierarchical
123+
profiling infrastructure, which is activated via `CARGO_PROFILE` variable
124+
125+
```
126+
# Outputs all logs with levels debug and higher
127+
$ RUST_LOG=debug cargo generate-lockfile
128+
129+
# Don't forget that you can filter by module as well
130+
$ RUST_LOG=cargo::core::resolver=trace cargo generate-lockfile
131+
132+
# Output first three levels of profiling info
133+
$ CARGO_PROFILE=3 cargo generate-lockfile
134+
```

0 commit comments

Comments
 (0)