-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix: profile events storage relatively to insertion timestamp #144
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,7 +114,56 @@ export class SpokePoolIndexerDataHandler implements IndexerDataHandler { | |
); | ||
await this.updateNewDepositsWithIntegratorId(newInsertedDeposits); | ||
await this.spokePoolProcessor.process(storedEvents); | ||
this.profileStoreEvents(storedEvents); | ||
} | ||
|
||
/** | ||
* Log the time that it took to store the events from the moment they were emitted onchain | ||
* @param events | ||
*/ | ||
private profileStoreEvents(events: StoreEventsResult) { | ||
const insertedDeposits = indexerDatabaseUtils.filterSaveQueryResults( | ||
events.deposits, | ||
SaveQueryResultType.Inserted, | ||
); | ||
|
||
// Log the time difference for each deposit event for profiling in datadog | ||
insertedDeposits.forEach((event) => { | ||
if (event.blockTimestamp === undefined) return; | ||
const timeDifference = | ||
event.createdAt.getTime() - event.blockTimestamp.getTime(); | ||
this.logger.debug({ | ||
at: "SpokePoolIndexerDataHandler#profileStoreEvents", | ||
message: "V3FundsDeposited event profile", | ||
depositId: event.depositId, | ||
originChainId: event.originChainId, | ||
timeDifference, | ||
createdAt: event.createdAt, | ||
blockTimestamp: event.blockTimestamp, | ||
}); | ||
}); | ||
Comment on lines
+130
to
+144
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OOC would it make sense to spot-check a few of these values? Since this is an O(N) operation, it could add noticeable milliseconds to the process, and it seems worth optimizing to shave down execution time as much as possible There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. at some point we might reduce the number of logs, yes. I will introduce an ENV var to disable this while doing large backfills |
||
|
||
const insertedFills = indexerDatabaseUtils.filterSaveQueryResults( | ||
events.fills, | ||
SaveQueryResultType.Inserted, | ||
); | ||
insertedFills.forEach((event) => { | ||
if (event.blockTimestamp === undefined) return; | ||
const timeDifference = | ||
event.createdAt.getTime() - event.blockTimestamp.getTime(); | ||
this.logger.debug({ | ||
at: "SpokePoolIndexerDataHandler#profileStoreEvents", | ||
message: "FilledV3Relay event profile", | ||
depositId: event.depositId, | ||
originChainId: event.originChainId, | ||
destinationChainId: event.destinationChainId, | ||
timeDifference, | ||
createdAt: event.createdAt, | ||
blockTimestamp: event.blockTimestamp, | ||
}); | ||
}); | ||
} | ||
|
||
private async getBlockTime(blockNumber: number): Promise<number> { | ||
const block = await this.provider.getBlock(blockNumber); | ||
if (!block) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the two async functions above this be called in parallel?