-
Notifications
You must be signed in to change notification settings - Fork 206
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
base: main
Are you sure you want to change the base?
Conversation
…d-optimizer-tiers
…d-optimizer-tiers
…d-optimizer-tiers
…d-optimizer-tiers
retrySecondChanceAfter = time.Minute * 3 | ||
DebugProbes = false | ||
CollectOptimizerProvidersScore = false | ||
CollectOptimizerProvidersScoreFlagName = "collect-optimizer-providers-score" |
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.
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{} |
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.
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 { |
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.
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) |
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.
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) |
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.
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) |
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.
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) |
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.
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 |
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.
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) |
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.
You're already in a go routine. you can call this one synchronously
No description provided.