Skip to content

Commit

Permalink
Improved graph500 performance (Issue #2719)
Browse files Browse the repository at this point in the history
  • Loading branch information
eholk committed Jun 25, 2012
1 parent e991855 commit 07e1d1c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/libcore/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pure fn from_fn<T>(n_elts: uint, op: init_op<T>) -> [T] {
let mut v = [];
unchecked{reserve(v, n_elts);}
let mut i: uint = 0u;
while i < n_elts { v += [op(i)]; i += 1u; }
while i < n_elts unsafe { push(v, op(i)); i += 1u; }
ret v;
}

Expand Down Expand Up @@ -564,7 +564,7 @@ Apply a function to each element of a vector and return the results
pure fn mapi<T, U>(v: [T]/&, f: fn(uint, T) -> U) -> [U] {
let mut result = [];
unchecked{reserve(result, len(v));}
for eachi(v) {|i, elem| result += [f(i, elem)]; }
for eachi(v) {|i, elem| unsafe { push(result, f(i, elem)); } }
ret result;
}

Expand Down
5 changes: 3 additions & 2 deletions src/libstd/par.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn map_slices<A: copy send, B: copy send>(
// FIXME: why is the ::<A, ()> annotation required here? (#2617)
vec::unpack_slice::<A, ()>(xs) {|p, _len|
let f = f();
futures += [future::spawn() {|copy base|
let f = future::spawn() {|copy base|
unsafe {
let len = end - base;
let slice = (ptr::offset(p, base),
Expand All @@ -55,7 +55,8 @@ fn map_slices<A: copy send, B: copy send>(
assert(vec::len(slice) == end - base);
f(base, slice)
}
}];
};
vec::push(futures, f);
};
base += items_per_task;
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/bench/graph500-bfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ fn validate(edges: [(node_id, node_id)],
status = false;
}

path += [parent];
vec::push(path, parent);
parent = tree[parent];
}

Expand Down

0 comments on commit 07e1d1c

Please sign in to comment.