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

feat: PRT - Optimizer metrics - including tiers #1701

Draft
wants to merge 47 commits into
base: main
Choose a base branch
from

Conversation

shleikes
Copy link
Collaborator

No description provided.

shleikes and others added 30 commits September 5, 2024 16:25
Copy link

Test Results

2 205 tests  ±0   2 205 ✅ ±0   25m 14s ⏱️ -8s
  145 suites ±0       0 💤 ±0 
    7 files   ±0       0 ❌ ±0 

Results for commit a8be23a. ± Comparison against base commit 6278d1a.

retrySecondChanceAfter = time.Minute * 3
DebugProbes = false
CollectOptimizerProvidersScore = false
CollectOptimizerProvidersScoreFlagName = "collect-optimizer-providers-score"
Copy link
Collaborator

Choose a reason for hiding this comment

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

put flag names in cobra common
cobra_common.go

@@ -114,6 +118,19 @@ func (csm *ConsumerSessionManager) UpdateAllProviders(epoch uint64, pairingList
csm.setValidAddressesToDefaultValue("", nil) // the starting point is that valid addresses are equal to pairing addresses.
// reset session related metrics
csm.consumerMetricsManager.ResetSessionRelatedMetrics()
stakeEntriesForMetrics := map[string]uint64{}
Copy link
Collaborator

Choose a reason for hiding this comment

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

put this chunk of code in a method.

@@ -639,7 +656,10 @@ func (csm *ConsumerSessionManager) getValidProviderAddresses(ignoredProvidersLis
if stateful == common.CONSISTENCY_SELECT_ALL_PROVIDERS && csm.providerOptimizer.Strategy() != provideroptimizer.STRATEGY_COST {
providers = csm.getTopTenProvidersForStatefulCalls(validAddresses, ignoredProvidersList)
} else {
providers, _ = csm.providerOptimizer.ChooseProvider(validAddresses, ignoredProvidersList, cu, requestedBlock)
providers, _ = csm.providerOptimizer.ChooseProvider(validAddresses, ignoredProvidersList, cu, requestedBlock, csm.currentEpoch)
for _, chosenProvider := range providers {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of X routines, I would rather open one routine with all the data needed. can you just pass all the necessary data to the routine and call it once?

return
case <-time.After(CollectOptimizerProvidersScoreInterval):
// collect optimizer providers score
selectionTier, _ := csm.providerOptimizer.CalculateSelectionTiers(csm.validAddresses, nil, 10, spectypes.LATEST_BLOCK)
Copy link
Collaborator

Choose a reason for hiding this comment

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

reading without locks.

@@ -1068,7 +1088,7 @@ func (csm *ConsumerSessionManager) updateMetricsManager(consumerSession *SingleC
publicProviderAddress := consumerSession.Parent.PublicLavaAddress

go func() {
csm.consumerMetricsManager.SetQOSMetrics(chainId, apiInterface, publicProviderAddress, lastQos, lastQosExcellence, consumerSession.LatestBlock, consumerSession.RelayNum, relayLatency, sessionSuccessful)
csm.consumerMetricsManager.SetQOSMetrics(chainId, apiInterface, publicProviderAddress, lastQos, lastQosExcellence, consumerSession.LatestBlock, consumerSession.RelayNum, relayLatency, sessionSuccessful, csm.currentEpoch)
Copy link
Collaborator

Choose a reason for hiding this comment

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

use csm.atomicReadCurrentEpoch(), you are not locked here.

return
case <-time.After(CollectOptimizerProvidersScoreInterval):
// collect optimizer providers score
selectionTier, _ := csm.providerOptimizer.CalculateSelectionTiers(csm.validAddresses, nil, 10, spectypes.LATEST_BLOCK)
Copy link
Collaborator

Choose a reason for hiding this comment

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

you are not using ShiftTierChance, we want both data (shifted tiers are tier odds with shifted chances based on QOS)

selectionTier, _ := csm.providerOptimizer.CalculateSelectionTiers(csm.validAddresses, nil, 10, spectypes.LATEST_BLOCK)
metricsTiers := []metrics.ProviderTierEntry{}
for i := 0; i < provideroptimizer.OptimizerNumTiers; i++ {
tierEntries := selectionTier.GetTier(i, provideroptimizer.OptimizerNumTiers, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why use 1 minimum instead of default values?
tierProviders := selectionTier.GetTier(tier, po.OptimizerNumTiers, MinimumEntries)

case <-ctx.Done():
return
case <-time.After(CollectOptimizerProvidersScoreInterval):
// collect optimizer providers score
Copy link
Collaborator

Choose a reason for hiding this comment

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

This entire case can be added to the Optimizer's internal methods and be called here

}
}

go csm.consumerMetricsManager.UpdateOptimizerProvidersScore(csm.rpcEndpoint.ChainID, csm.rpcEndpoint.ApiInterface, csm.currentEpoch, metricsTiers)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You're already in a go routine. you can call this one synchronously

@ranlavanet ranlavanet marked this pull request as draft September 24, 2024 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants