Skip to content

Commit 325f7df

Browse files
committed
---
yaml --- r: 31644 b: refs/heads/dist-snap c: f57760c h: refs/heads/master v: v3
1 parent 03c5b56 commit 325f7df

File tree

3 files changed

+70
-3
lines changed

3 files changed

+70
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: fe2f3d210a536ea951596c7df491c9b1d33764e0
10+
refs/heads/dist-snap: f57760c609d636d2e4698a26848f5c990d417265
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/src/test/bench/task-perf-jargon-metal-smoke.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
// Each child task has to enlist as a descendant in each of its ancestor
44
// groups, but that shouldn't have to happen for already-dead groups.
55
//
6-
// The filename is a reference; google it in quotes.
6+
// The filename is a song reference; google it in quotes.
77

88
fn child_generation(gens_left: uint) {
99
// This used to be O(n^2) in the number of generations that ever existed.
1010
// With this code, only as many generations are alive at a time as tasks
11-
// alive at a time,
11+
// alive at a time,
1212
do task::spawn_supervised {
1313
if gens_left & 1 == 1 {
1414
task::yield(); // shake things up a bit
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* Test performance of killing many tasks in a taskgroup.
3+
* Along the way, tests various edge cases of ancestor group management.
4+
* In particular, this tries to get each grandchild task to hit the
5+
* "nobe_is_dead" case in each_ancestor only during task exit, but not during
6+
* task spawn. This makes sure that defunct ancestor groups are handled correctly
7+
* w.r.t. possibly leaving stale *rust_tasks lying around.
8+
*/
9+
10+
// Creates in the background 'num_tasks' tasks, all blocked forever.
11+
// Doesn't return until all such tasks are ready, but doesn't block forever itself.
12+
fn grandchild_group(num_tasks: uint) {
13+
let po = comm::port();
14+
let ch = comm::chan(po);
15+
16+
for num_tasks.times {
17+
do task::spawn { // linked
18+
comm::send(ch, ());
19+
comm::recv(comm::port::<()>()); // block forever
20+
}
21+
}
22+
#error["Grandchild group getting started"];
23+
for num_tasks.times {
24+
// Make sure all above children are fully spawned; i.e., enlisted in
25+
// their ancestor groups.
26+
comm::recv(po);
27+
}
28+
#error["Grandchild group ready to go."];
29+
// Master grandchild task exits early.
30+
}
31+
32+
fn spawn_supervised_blocking(myname: &str, +f: fn~()) {
33+
let mut res = none;
34+
task::task().future_result(|-r| res = some(r)).supervised().spawn(f);
35+
#error["%s group waiting", myname];
36+
let x = future::get(option::unwrap(res));
37+
assert x == task::success;
38+
}
39+
40+
fn main(args: ~[~str]) {
41+
let args = if os::getenv(~"RUST_BENCH").is_some() {
42+
~[~"", ~"100000"]
43+
} else if args.len() <= 1u {
44+
~[~"", ~"100"]
45+
} else {
46+
copy args
47+
};
48+
49+
let num_tasks = uint::from_str(args[1]).get();
50+
51+
// Main group #0 waits for unsupervised group #1.
52+
// Grandparent group #1 waits for middle group #2, then fails, killing #3.
53+
// Middle group #2 creates grandchild_group #3, waits for it to be ready, exits.
54+
let x: result::result<(),()> = do task::try { // unlinked
55+
do spawn_supervised_blocking("grandparent") {
56+
do spawn_supervised_blocking("middle") {
57+
grandchild_group(num_tasks);
58+
}
59+
// When grandchild group is ready to go, make the middle group exit.
60+
#error["Middle group wakes up and exits"];
61+
}
62+
// Grandparent group waits for middle group to be gone, then fails
63+
#error["Grandparent group wakes up and fails"];
64+
fail;
65+
};
66+
assert x.is_err();
67+
}

0 commit comments

Comments
 (0)