Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mds-cache] Add more granular readAllEvents performance logging #80

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/mds-cache/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,25 @@ async function readEvents(device_ids: UUID[]): Promise<VehicleEvent[]> {

async function readAllEvents(): Promise<Array<VehicleEvent | null>> {
// 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) {
Expand Down