Skip to content

Commit

Permalink
Benchmark resolver. Disabled an optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
orium committed Mar 30, 2018
1 parent 434c702 commit 759d663
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
66 changes: 66 additions & 0 deletions cargo-bench.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
LOOPS=20

function median() {
left=$(cut -d' ' -f2 $1 | sort -n | tail -$(($LOOPS/2)) | head -1)
right=$(cut -d' ' -f2 $1 | sort -n | tail -$(($LOOPS/2+1)) | head -1)

echo $((($left+$right)/2))
}

function avg() {
sum=0

for v in $(cut -d' ' -f2 $1); do
sum=$(($sum+$v))
done

echo $(($sum/$LOOPS))
}



for i in $(seq 1 $LOOPS); do
echo -n "$i "

CARGO_PROFILE=1 cargo-master generate-lockfile -v 2>&1 \
| grep resolve-main-loop | grep -o '[0-9]*'
done | tee cargo-master

echo "MASTER Median $(median cargo-master)"
echo "MASTER Average $(avg cargo-master)"

for i in $(seq 1 $LOOPS); do
echo -n "$i "

CARGO_PROFILE=1 cargo-rpds generate-lockfile -v 2>&1 \
| grep resolve-main-loop | grep -o '[0-9]*'
done | tee cargo-rpds

echo "RPDS Median $(median cargo-rpds)"
echo "RPDS Average $(avg cargo-rpds)"

for i in $(seq 1 $LOOPS); do
echo -n "$i "

CARGO_PROFILE=1 cargo-rpds-rc generate-lockfile -v 2>&1 \
| grep resolve-main-loop | grep -o '[0-9]*'
done | tee cargo-rpds-rc

echo "RPDS-RC Median $(median cargo-rpds-rc)"
echo "RPDS-RC Average $(avg cargo-rpds-rc)"

# RUST resolve-main-loop
#
# MASTER Median 35
# MASTER Average 35
# RPDS Median 32
# RPDS Average 32

# SERVO resolve-main-loop
#
# MASTER Median 1870
# MASTER Average 2640
# RPDS Median 1695
# RPDS Average 2805
# RPDS-RC Median 1339
# RPDS-RC Average 3221
17 changes: 16 additions & 1 deletion src/cargo/core/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,8 @@ fn activate_deps_loop(
let mut printed = false;
let mut deps_time = Duration::new(0, 0);

let _p = profile::start("resolve-main-loop");

// Main resolution loop, this is the workhorse of the resolution algorithm.
//
// You'll note that a few stacks are maintained on the side, which might
Expand Down Expand Up @@ -1043,6 +1045,18 @@ fn activate_deps_loop(
}
}

if ticks % 1000000 == 0 {
let e = start.elapsed();
println!("{} ticks, {}s, {:.3} ticks/ms, {}, {}",
ticks,
e.as_secs(),
ticks as f32 / (e.as_secs() as f32 * 1000.0),
cx.activations.iter().map(|x| x.1.len()).sum::<usize>(),
// past_conflicting_activations.iter().map(|x| x.1.len()).sum::<usize>(),
remaining_deps.len(),
);
}

let just_here_for_the_error_messages = deps_frame.just_for_error_messages;

// Figure out what our next dependency to activate is, and if nothing is
Expand Down Expand Up @@ -1262,7 +1276,8 @@ fn activate_deps_loop(
// dependency can't be activated which implies that we
// ourselves are incompatible with that dep, so we know that deps
// parent conflict with us.
if !has_past_conflicting_dep {
// WIP WIP WIP WIP WIP WIP
if false && !has_past_conflicting_dep {
if let Some(known_related_bad_deps) =
past_conflicting_activations.dependencies_conflicting_with(&pid)
{
Expand Down

0 comments on commit 759d663

Please sign in to comment.