-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Cache parsed SQL when building sequence diagram
- Loading branch information
Showing
5 changed files
with
45 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { AppMap, Event } from '@appland/models'; | ||
import { classNameToOpenAPIType } from '@appland/openapi'; | ||
import sha256 from 'crypto-js/sha256.js'; | ||
import LRUCache from 'lru-cache'; | ||
import { merge } from './mergeWindow'; | ||
import { selectEvents } from './selectEvents'; | ||
import Specification from './specification'; | ||
|
@@ -19,6 +20,7 @@ import { | |
} from './types'; | ||
|
||
const MAX_WINDOW_SIZE = 5; | ||
const parsedSqlCache = new LRUCache<string, any>({ max: 1000 }); | ||
|
||
class ActorManager { | ||
private _actorsByCodeObjectId = new Map<string, Actor>(); | ||
|
@@ -68,7 +70,7 @@ export default function buildDiagram( | |
callee: actorManager.findOrCreateActor(callee), | ||
route: callee.route, | ||
status: response.status || response.status_code, | ||
digest: callee.hash, | ||
digest: callee.getHashWithSqlCache(parsedSqlCache), | ||
subtreeDigest: 'undefined', | ||
children: [], | ||
elapsed: callee.elapsedTime, | ||
|
@@ -83,7 +85,7 @@ export default function buildDiagram( | |
callee: actorManager.findOrCreateActor(callee), | ||
route: callee.route, | ||
status: response.status || response.status_code, | ||
digest: callee.hash, | ||
digest: callee.getHashWithSqlCache(parsedSqlCache), | ||
subtreeDigest: 'undefined', | ||
children: [], | ||
elapsed: callee.elapsedTime, | ||
|
@@ -96,7 +98,7 @@ export default function buildDiagram( | |
caller: caller ? actorManager.findOrCreateActor(caller) : undefined, | ||
callee: actorManager.findOrCreateActor(callee), | ||
query: callee.sqlQuery, | ||
digest: truncatedQuery ? 'truncatedQuery' : callee.hash, | ||
digest: truncatedQuery ? 'truncatedQuery' : callee.getHashWithSqlCache(parsedSqlCache), | ||
This comment has been minimized.
Sorry, something went wrong.
kgilpin
Contributor
|
||
subtreeDigest: 'undefined', | ||
children: [], | ||
elapsed: callee.elapsedTime, | ||
|
@@ -109,7 +111,7 @@ export default function buildDiagram( | |
callee: actorManager.findOrCreateActor(callee), | ||
name: callee.codeObject.name, | ||
static: callee.codeObject.static, | ||
digest: callee.hash, | ||
digest: callee.getHashWithSqlCache(parsedSqlCache), | ||
subtreeDigest: 'undefined', | ||
stableProperties: { ...callee.stableProperties }, | ||
returnValue: buildReturnValue(callee), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I think this can be removed, and clients that want to provide a cache can just call
buildStableHash(cache).digest();
. Because it's kind of a combination builder/getter and it's not clear from the interface whenparsedSqlCache
is used and whether or not it's rquired.