-
Notifications
You must be signed in to change notification settings - Fork 98
Add caching and query DB less frequently #6132
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
Conversation
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.
I'm not sure how much of that would be effectively cached by the SQL database though.
@@ -18,24 +18,41 @@ pub trait HoprDbResolverOperations { | |||
#[async_trait] | |||
impl HoprDbResolverOperations for HoprDb { | |||
async fn resolve_packet_key(&self, onchain_key: &Address) -> Result<Option<OffchainPublicKey>> { |
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.
Theoretically this API could disappear and the OffchainKeyOrAddress
could take a Arc reference and resolve dynamically into either Address
or OffchainKey
, this creating a sort of "UniversalAddress".
@@ -1397,6 +1392,7 @@ impl HoprDbTicketOperations for HoprDb { | |||
)) | |||
})?; | |||
|
|||
// TODO: cache this DB call too, or use the channel graph |
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.
The question is whether the SQLite cache is not sufficient, not only here, but in multiple tables and values that rarely change.
This PR introduces the following changes:
get_indexer_data
andget_safe_info
DB calls are now using cache. The Indexer data especially is query very frequently across the entire code base, and changes very sporadically. Therefore, proper caching has been introduced along with the invalidation when the underlying data changes in the DB.resolve_chain_key
andresolve_packet_key
also use cache, so packet processing pipeline can benefit from it. These calls are very often called directly from the packet processing pipeline.All caches that are used by the DB and
TicketManager
have been moved into a separate object. This object is then referenced viaArc
in the DB andTicketManager
to allow fast cloning.set_last_indexed_block
was separated into a standalone method, to avoid invalidating Indexer Data cache too often.Integration tests were enhanced
Several unused features and dependencies were removed
Closes #6045