From eb7a1e0992e68a5e2acc5dc1b7340fe7eb9c94ca Mon Sep 17 00:00:00 2001 From: Neil Goldader Date: Mon, 18 Nov 2019 13:07:28 -0500 Subject: [PATCH] Add more granular readAllEvents performance logging --- packages/mds-cache/index.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/mds-cache/index.ts b/packages/mds-cache/index.ts index 540bc4860..02b74733e 100644 --- a/packages/mds-cache/index.ts +++ b/packages/mds-cache/index.ts @@ -301,14 +301,25 @@ async function readEvents(device_ids: UUID[]): Promise { async function readAllEvents(): Promise> { // FIXME wildcard searching is slow + let start = now() const keys = await readKeys('device:*:event') + let finish = now() + let timeElapsed = finish - start + await log.info(`MDS-DAILY /admin/events -> cache.readAllEvents() readKeys() time elapsed: ${timeElapsed}`) const device_ids = keys.map(key => { const [, device_id] = key.split(':') return device_id }) - return (await hreads(['event'], device_ids)).map(event => { + + start = now() + const result = (await hreads(['event'], device_ids)).map(event => { return parseEvent(event as StringifiedEventWithTelemetry) }) + finish = now() + timeElapsed = finish - start + await log.info(`MDS-DAILY /admin/events -> cache.readAllEvents() hreads() time elapsed: ${timeElapsed}`) + + return result } async function readDevice(device_id: UUID) {