Skip to content

Commit 12a342e

Browse files
committed
Record implicit dependency for 'cached' predicates
1 parent 6329d23 commit 12a342e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

extensions/ql-vscode/src/log-insights/performance-comparison.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export class PerformanceOverviewScanner implements EvaluationLogScanner {
7575
dependencyLists: [],
7676
};
7777
private readonly raToIndex = new Map<string, number>();
78+
private readonly nameToIndex = new Map<string, number>();
7879

7980
private getPredicateIndex(name: string, ra: string): number {
8081
let index = this.raToIndex.get(ra);
@@ -114,8 +115,21 @@ export class PerformanceOverviewScanner implements EvaluationLogScanner {
114115
}
115116

116117
switch (evaluationStrategy) {
117-
case "EXTENSIONAL":
118+
case "EXTENSIONAL": {
119+
break;
120+
}
118121
case "COMPUTED_EXTENSIONAL": {
122+
if (predicateName.startsWith("cached_")) {
123+
// Add a dependency from a cached COMPUTED_EXTENSIONAL to the predicate with the actual contents.
124+
// The raHash of the this event may appear in a CACHE_HIT events in the other event log. The dependency
125+
// we're adding here is needed in order to associate the original predicate with such a cache hit.
126+
const originalName = predicateName.substring("cached_".length);
127+
const originalIndex = this.nameToIndex.get(originalName);
128+
if (originalIndex != null) {
129+
const index = this.getPredicateIndex(predicateName, raHash);
130+
this.data.dependencyLists[index].push(originalIndex);
131+
}
132+
}
119133
break;
120134
}
121135
case "CACHE_HIT":
@@ -140,6 +154,7 @@ export class PerformanceOverviewScanner implements EvaluationLogScanner {
140154
case "NAMED_LOCAL":
141155
case "IN_LAYER": {
142156
const index = this.getPredicateIndex(predicateName, raHash);
157+
this.nameToIndex.set(predicateName, index);
143158
let totalTime = 0;
144159
let totalTuples = 0;
145160
if (evaluationStrategy === "COMPUTE_SIMPLE") {

0 commit comments

Comments
 (0)