Skip to content

Commit

Permalink
Add tracing, remove heuristic (bis)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmondada committed Oct 3, 2023
1 parent 283c0c0 commit c39e8be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/optimiser/taso/hugr_pchannel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ where
// The senders have closed the channel, we can stop.
break;
};
self.recv(new_circs);
self.enqueue_circs(new_circs);
} else {
select! {
recv(self.push) -> result => {
let Ok(new_circs) = result else {
// The senders have closed the channel, we can stop.
break;
};
self.recv(new_circs);
self.enqueue_circs(new_circs);
}
send(self.pop, {let Entry {hash, circ, ..} = self.pq.pop().unwrap(); (hash, circ)}) -> result => {
match result {
Expand Down Expand Up @@ -171,13 +171,12 @@ where
}

/// Add circuits to queue.
fn recv(&mut self, circs: Vec<(u64, Hugr)>) {
#[tracing::instrument(target = "taso::metrics", skip(self, circs))]
fn enqueue_circs(&mut self, circs: Vec<(u64, Hugr)>) {
for (hash, circ) in circs {
let cost = (self.pq.cost_fn)(&circ);
if (self.pq.len() > self.queue_capacity / 2 && cost > *self.pq.max_cost().unwrap())
|| !self.seen_hashes.insert(hash)
{
// Ignore this circuit: it's either too big or we've seen it before.
if !self.seen_hashes.insert(hash) {
// Ignore this circuit: we've seen it before.
continue;
}

Expand Down
1 change: 1 addition & 0 deletions src/optimiser/taso/hugr_pqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ impl<P: Ord, C> HugrPQ<P, C> {
}

/// The largest cost in the queue.
#[allow(unused)]
pub(super) fn max_cost(&self) -> Option<&P> {
self.queue.peek_max().map(|(_, cost)| cost)
}
Expand Down

0 comments on commit c39e8be

Please sign in to comment.