Skip to content

Commit

Permalink
(feat) changed indexing instrategy for traces and added less paralel …
Browse files Browse the repository at this point in the history
…mode for profiling
  • Loading branch information
jspaezp committed Jul 22, 2024
1 parent c9b8993 commit ec2f3c5
Show file tree
Hide file tree
Showing 14 changed files with 694 additions and 245 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ IONMESH_PROFILE_NUM_WINDOWS
# windows.
```

### Profiling

Mostly notes to self but someone else might benefit ...

```
# Making a cool flamegraph of a run
sudo RUST_LOG=debug CARGO_PROFILE_RELEASE_DEBUG=true IONMESH_PROFILE_NUM_WINDOWS=2 \
cargo flamegraph \
--output flamegraph_secondversion.svg \
--features less_parallel \
-- --config ./benchmark/default_ionmesh_config.toml benchmark/${MYFAVORITEFILE}.d -o tmp/
```

## Roadmap

1. Use aggregation metrics to re-score sage search.
Expand Down
50 changes: 26 additions & 24 deletions src/aggregation/aggregators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,33 +181,35 @@ fn parallel_aggregate_clusters<

let mut cluster_vecs = out2.into_iter().flatten().collect::<Vec<_>>();

let unclustered_elems: Vec<usize> = cluster_labels
.iter()
.enumerate()
.filter(|(_, x)| match x {
ClusterLabel::Unassigned => true,
ClusterLabel::Noise => keep_unclustered,
_ => false,
})
.map(|(i, _elem)| i)
.collect();
if keep_unclustered {
let unclustered_elems: Vec<usize> = cluster_labels
.iter()
.enumerate()
.filter(|(_, x)| match x {
ClusterLabel::Unassigned => true, // Should there be any unassigned?
ClusterLabel::Noise => true,
ClusterLabel::Cluster(_) => false,
})
.map(|(i, _elem)| i)
.collect();

// if unclustered_elems.len() > 0 {
// log::debug!("Total Orig elems: {}", cluster_labels.len());
// log::debug!("Unclustered elems: {}", unclustered_elems.len());
// log::debug!("Clustered elems: {}", cluster_vecs.len());
// }
// if unclustered_elems.len() > 0 {
// log::debug!("Total Orig elems: {}", cluster_labels.len());
// log::debug!("Unclustered elems: {}", unclustered_elems.len());
// log::debug!("Clustered elems: {}", cluster_vecs.len());
// }

let unclustered_elems = unclustered_elems
.iter()
.map(|i| {
let mut oe = def_aggregator();
oe.add(&elements.get_aggregable_at_index(*i));
oe
})
.collect::<Vec<_>>();
let unclustered_elems = unclustered_elems
.iter()
.map(|i| {
let mut oe = def_aggregator();
oe.add(&elements.get_aggregable_at_index(*i));
oe
})
.collect::<Vec<_>>();

cluster_vecs.extend(unclustered_elems);
cluster_vecs.extend(unclustered_elems);
}

timer.stop(true);
cluster_vecs
Expand Down
7 changes: 6 additions & 1 deletion src/aggregation/chromatograms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,12 @@ impl<
let mut mag_a = T::default();
let mut mag_b = T::default();
for i in 0..NBINS {
let other_index = i + other_vs_self_offset as usize;
let other_index = i as i32 + other_vs_self_offset;
if other_index < 0 {
continue;
}

let other_index = other_index as usize;
if other_index >= other.chromatogram.len() {
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/aggregation/dbscan/dbscan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn reassign_centroid<
const N: usize,
T: Send + Clone + Copy,
C: NDPointConverter<R, N>,
I: QueriableIndexedPoints<'a, N> + std::marker::Sync,
I: QueriableIndexedPoints<N> + std::marker::Sync,
G: Sync + Send + ClusterAggregator<T, R>,
R: Send,
RE: Send + Sync + AsAggregableAtIndex<T> + ?Sized,
Expand Down Expand Up @@ -167,7 +167,7 @@ pub fn dbscan_aggregate<
+ Sync
+ std::fmt::Debug
+ ?Sized,
IND: QueriableIndexedPoints<'a, N> + std::marker::Sync + Send + std::fmt::Debug,
IND: QueriableIndexedPoints<N> + std::marker::Sync + Send + std::fmt::Debug,
NAI: AsNDPointsAtIndex<N> + std::marker::Sync + Send,
T: HasIntensity + Send + Clone + Copy + Sync,
D: Send + Sync,
Expand Down
Loading

0 comments on commit ec2f3c5

Please sign in to comment.