Skip to content

Commit

Permalink
fix(insights): improve files per cluster (#5388)
Browse files Browse the repository at this point in the history
Increase clustering distance which should result in creation of fewer clusters.
Fewer clusters means that less files should be downloaded to the client
(each file will have more symbols.) This should improve performance.
  • Loading branch information
mhevery authored Nov 2, 2023
1 parent fea6582 commit 15fae10
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ export const CorrelationMatrix = component$<{
<div
class={css({
border: `1px solid black`,
height: 'calc(100vmin - 20px)',
width: 'calc(100vmin - 20px)',
height: 'calc(80vmin - 20px)',
width: 'calc(80vmin - 20px)',
flexDirection: 'column',
justifyContent: 'space-evenly',
})}
Expand Down
3 changes: 2 additions & 1 deletion packages/insights/src/stats/edges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export function computeBundles(symbolVectors: SymbolVectors): Bundle[] {
const bundles: Bundle[] = [];
const dbscan = new DBSCAN();
// We want to set the distance so that it is just bellow (90%) the distance between two unrelated symbols.
const maxDistance = 0.9 * Math.sqrt(Math.pow(1, 2) + Math.pow(1, 2));
const maxDistance = 0.95 * Math.sqrt(Math.pow(1, 2) + Math.pow(1, 2));
const clusters = dbscan.run(symbolVectors.vectors, maxDistance, 1);
clusters.forEach((cluster) => {
const symbols = cluster.map((id) => symbolVectors.symbols[id]);
Expand All @@ -215,6 +215,7 @@ export function computeBundles(symbolVectors: SymbolVectors): Bundle[] {
symbols,
});
});
bundles.sort((b1, b2) => b2.symbols.length - b1.symbols.length);
return bundles;
}

Expand Down

0 comments on commit 15fae10

Please sign in to comment.