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

fix: profile events storage relatively to insertion timestamp #144

Merged

Conversation

amateima
Copy link
Contributor

@amateima amateima commented Jan 2, 2025

For more accurate profiling, we need to compute the time difference relatively to the time the event was inserted in the DB, not the current now() server timestamp at logging time.

In addition, now we profile fill events storing too

Copy link

linear bot commented Jan 2, 2025

Comment on lines +130 to +144
// 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,
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

@@ -114,7 +114,56 @@ export class SpokePoolIndexerDataHandler implements IndexerDataHandler {
);
await this.updateNewDepositsWithIntegratorId(newInsertedDeposits);
await this.spokePoolProcessor.process(storedEvents);
this.profileStoreEvents(storedEvents);
Copy link
Contributor

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?

Copy link
Contributor

@daywiss daywiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice changes

@amateima amateima merged commit c31f0e5 into master Jan 7, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants