-
Notifications
You must be signed in to change notification settings - Fork 33
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
Speed up GetCommittableBalance #2962
Comments
To speed up
CREATE INDEX idx_status ON request_for_quotes(status);
Files to Update:
Example Code: // Cache structure
var committableBalanceCache map[string]Balance
// GetCommittableBalances with caching
func GetCommittableBalances() Balance {
if balance, found := committableBalanceCache["key"]; found {
return balance
}
// Original SQL query
balance := queryDatabase()
committableBalanceCache["key"] = balance
return balance
}
// HasSufficientGas using cached balance
func HasSufficientGas() bool {
balance := GetCommittableBalances()
// Logic to check gas
} This approach reduces redundant database calls and improves performance. References/services/rfq/relayer/inventory/manager.go
|
As I was going through a trace to look for speedup opps I've realized 90% of our latency exists in a single sql query:
SELECT * FROM
request_for_quotesWHERE status IN (5,6,7)
This query is called in GetCommittableBalances which is called in
HasSufficientGas
which in turn is called twice sequentially (#2960).Amazingly, it's then called a third time in
forward-Seen
:Moving on to forward-ComimttedPending we call it 2x more sequentially
Then again in 2x more in forward-CommittedConfirmed:
The text was updated successfully, but these errors were encountered: