EmerisHQ / tracelistener

UNIX named pipes-based real-time state listener for Cosmos SDK blockchains
GNU Affero General Public License v3.0
33 stars 8 forks source link

Added Jitter on DB insert #121

Closed DeshErBojhaa closed 2 years ago

DeshErBojhaa commented 2 years ago

Addresses:

Adds:

tbruyelle commented 2 years ago

@DeshErBojhaa I don't understand the need to add a random delay before each insert, can you explain please?

DeshErBojhaa commented 2 years ago

@DeshErBojhaa I don't understand the need to add a random delay before each insert, can you explain please?

Absolutely! All the chains creates block at seconds granularity. That means our flush function in TL will be called at second's granularity. Which clutters the DB call on cockroach. This PR ensures that we don't go to the DB once at a time (at the begening of the second). Rather we spread calls to DB throughout the second. (Actually haft of a second, but the same idea).

Please let me know if this clarifies the query.

tbruyelle commented 2 years ago

@DeshErBojhaa I don't understand the need to add a random delay before each insert, can you explain please?

Absolutely! All the chains creates block at seconds granularity. That means our flush function in TL will be called at second's granularity. Which clutters the DB call on cockroach. This PR ensures that we don't go to the DB once at a time (at the begening of the second). Rather we spread calls to DB throughout the second. (Actually haft of a second, but the same idea).

Please let me know if this clarifies the query.

It's clear tyvm!

What about adding this explanation in the comments ?

Pitasi commented 2 years ago

Please let me know if this clarifies the query.

I'll send it again after some jitter.