Navigation Menu

Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
blorente committed Nov 13, 2018
1 parent 80ee872 commit 466c41f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/rust/engine/src/lib.rs
Expand Up @@ -54,6 +54,7 @@ extern crate fs;
extern crate futures;
extern crate graph;
extern crate hashing;
extern crate indexmap;
extern crate itertools;
extern crate lazy_static;
extern crate log;
Expand All @@ -64,7 +65,6 @@ extern crate reqwest;
extern crate resettable;
extern crate smallvec;
extern crate tempfile;
extern crate indexmap;
extern crate tokio;
extern crate ui;
extern crate url;
Expand Down
35 changes: 14 additions & 21 deletions src/rust/engine/src/scheduler.rs
Expand Up @@ -12,8 +12,8 @@ use futures::future::{self, Future};
use context::{Context, Core};
use core::{Failure, Key, Params, TypeConstraint, TypeId, Value};
use graph::{EntryId, Graph, InvalidationResult, Node, NodeContext};
use log::{debug, info, warn};
use indexmap::IndexMap;
use log::{debug, info, warn};
use nodes::{NodeKey, Select, Tracer, TryInto, Visualizer};
use parking_lot::Mutex;
use rule_graph;
Expand Down Expand Up @@ -300,25 +300,7 @@ impl Scheduler {
if let Ok(res) = receiver.recv_timeout(Duration::from_millis(100)) {
break res;
} else if let Some(display) = optional_display.as_mut() {
// Update the graph. To do that, we iterate over heavy hitters.
let mut heavy_hitters: Vec<(String, Duration)> = self
.core
.graph
.heavy_hitters(&roots, display.worker_count());
// Insert every one in the set of tasks to display.
for (task, duration) in &heavy_hitters {
// TODO I don't really want to trigger the clone unconditionally, but using an
// if x.contains {} here seems to kind of defeat the purpose of using a set
tasks_to_display.insert(task.clone(), *duration);
}
// And remove the tasks that no longer should be there.
for (task, duration) in tasks_to_display.clone().into_iter() {
let mut remove = false;
if !heavy_hitters.contains(&(task.to_string(), duration)) {
tasks_to_display.swap_remove(&task);
}
}
Scheduler::display_ongoing_tasks(&self.core.graph, &roots, display, &tasks_to_display);
Scheduler::display_ongoing_tasks(&self.core.graph, &roots, display, &mut tasks_to_display);
}
};
if let Some(display) = optional_display.as_mut() {
Expand All @@ -337,8 +319,19 @@ impl Scheduler {
graph: &Graph<NodeKey>,
roots: &[NodeKey],
display: &mut EngineDisplay,
tasks_to_display: &IndexMap<String, Duration>,
tasks_to_display: &mut IndexMap<String, Duration>,
) {
// Update the graph. To do that, we iterate over heavy hitters.
let heavy_hitters: Vec<(String, Duration)> =
graph.heavy_hitters(&roots, display.worker_count());
// Insert every one in the set of tasks to display.
tasks_to_display.extend(heavy_hitters.iter().cloned());
// And remove the tasks that no longer should be there.
for (task, duration) in tasks_to_display.clone().into_iter() {
if !heavy_hitters.contains(&(task.to_string(), duration)) {
tasks_to_display.swap_remove(&task);
}
}
let display_worker_count = display.worker_count();
let ongoing_tasks = tasks_to_display;
for (i, id) in ongoing_tasks.iter().enumerate() {
Expand Down

0 comments on commit 466c41f

Please sign in to comment.