[Profiling] Add TTL to cached frames and executables (#144292)

* Add TTL to cached frames and executables

* Fix misspelled constant
This commit is contained in:
Joseph Crail 2022-11-04 20:50:57 -07:00 committed by GitHub
parent 6bc74ae155
commit 1fdf4a6453
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,6 +36,9 @@ import { ProjectTimeQuery } from './query';
const BASE64_FRAME_ID_LENGTH = 32;
const CACHE_MAX_ITEMS = 100000;
const CACHE_TTL_MILLISECONDS = 1000 * 60 * 5;
export type EncodedStackTrace = DedotObject<{
// This field is a base64-encoded byte string. The string represents a
// serialized list of frame IDs in which the order of frames are
@ -270,7 +273,10 @@ export async function mgetStackTraces({
return { stackTraces, totalFrames, stackFrameDocIDs, executableDocIDs };
}
const frameLRU = new LRUCache<StackFrameID, StackFrame>({ max: 100000 });
const frameLRU = new LRUCache<StackFrameID, StackFrame>({
max: CACHE_MAX_ITEMS,
maxAge: CACHE_TTL_MILLISECONDS,
});
export async function mgetStackFrames({
logger,
@ -339,7 +345,10 @@ export async function mgetStackFrames({
return stackFrames;
}
const executableLRU = new LRUCache<FileID, Executable>({ max: 100000 });
const executableLRU = new LRUCache<FileID, Executable>({
max: CACHE_MAX_ITEMS,
maxAge: CACHE_TTL_MILLISECONDS,
});
export async function mgetExecutables({
logger,