This repository has been archived by the owner on Apr 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
More instrumentation of context cancellations and reward low latency nodes #85
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -202,12 +202,6 @@ func (p *pool) doRefresh() { | |
|
||
peerLatencyDistribution = latencyHist | ||
peerSpeedDistribution = speedHist | ||
|
||
// TODO: The orchestrator periodically prunes "bad" L1s based on a reputation system | ||
// it owns and runs. We should probably just forget about the Saturn endpoints that were | ||
// previously in the pool but are no longer being returned by the orchestrator. It's highly | ||
// likely that the Orchestrator has deemed them to be non-functional/malicious. | ||
// Let's just override the old pool with the new endpoints returned here. | ||
oldMap := make(map[string]bool) | ||
n := make([]*Member, 0, len(newEP)) | ||
for _, o := range p.endpoints { | ||
|
@@ -245,6 +239,20 @@ func (p *pool) doRefresh() { | |
} | ||
} | ||
|
||
// give weight bumps to low latency peers that have served > 100 successful "low latency" cache hit retrievals. | ||
poolWeightBumpMetric.Set(0) | ||
for _, m := range n { | ||
m := m | ||
if perf, ok := p.nodePerf[m.url]; ok { | ||
// Our analysis so far shows that we do have ~10-15 peers with -75 < 200ms latency. | ||
// It's not the best but it's a good start and we can tune as we go along. | ||
if perf.latencyDigest.Count() > 100 && perf.latencyDigest.Quantile(0.75) <= 200 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these parameters probably shouldn't be hard coded? - maybe environment variables at least? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @willscott Made these varibales for now. Will make them env in the next Caboose PR that I'm gonna write for much better pool membership and weighing algo. |
||
poolWeightBumpMetric.Add(1) | ||
m.weight = maxWeight | ||
} | ||
} | ||
} | ||
|
||
// If we have more than maxPoolSize nodes, pick the top maxPoolSize sorted by (weight * age). | ||
if len(n) > maxPoolSize { | ||
sort.Slice(n, func(i, j int) bool { | ||
|
@@ -262,7 +270,6 @@ func (p *pool) doRefresh() { | |
p.c.UpdateWithWeights(p.endpoints.ToWeights()) | ||
} | ||
poolSizeMetric.Set(float64(len(n))) | ||
|
||
poolNewMembersMetric.Reset() | ||
// periodic update of a pool health metric | ||
byWeight := make(map[int]int) | ||
|
@@ -329,6 +336,9 @@ func cidToKey(c cid.Cid) string { | |
} | ||
|
||
func (p *pool) fetchBlockWith(ctx context.Context, c cid.Cid, with string) (blk blocks.Block, err error) { | ||
if recordIfContextErr(resourceTypeBlock, ctx, "fetchBlockWith") { | ||
return nil, ctx.Err() | ||
} | ||
// wait for pool to be initialised | ||
<-p.started | ||
|
||
|
@@ -352,6 +362,9 @@ func (p *pool) fetchBlockWith(ctx context.Context, c cid.Cid, with string) (blk | |
|
||
blockFetchStart := time.Now() | ||
for i := 0; i < len(nodes); i++ { | ||
if recordIfContextErr(resourceTypeBlock, ctx, "fetchBlockWithLoop") { | ||
return nil, ctx.Err() | ||
} | ||
blk, err = p.fetchBlockAndUpdate(ctx, nodes[i], c, i) | ||
|
||
if err == nil { | ||
|
@@ -360,9 +373,6 @@ func (p *pool) fetchBlockWith(ctx context.Context, c cid.Cid, with string) (blk | |
|
||
return | ||
} | ||
if ce := ctx.Err(); ce != nil { | ||
return nil, ce | ||
} | ||
} | ||
|
||
fetchDurationBlockFailureMetric.Observe(float64(time.Since(blockFetchStart).Milliseconds())) | ||
|
@@ -471,6 +481,10 @@ func (p *pool) getNodesToFetch(key string, with string) ([]string, error) { | |
} | ||
|
||
func (p *pool) fetchResourceWith(ctx context.Context, path string, cb DataCallback, with string) (err error) { | ||
if recordIfContextErr(resourceTypeCar, ctx, "fetchResourceWith") { | ||
return ctx.Err() | ||
} | ||
|
||
// wait for pool to be initialised | ||
<-p.started | ||
|
||
|
@@ -496,6 +510,10 @@ func (p *pool) fetchResourceWith(ctx context.Context, path string, cb DataCallba | |
|
||
pq := []string{path} | ||
for i := 0; i < len(nodes); i++ { | ||
if recordIfContextErr(resourceTypeCar, ctx, "fetchResourceWithLoop") { | ||
return ctx.Err() | ||
} | ||
|
||
err = p.fetchResourceAndUpdate(ctx, nodes[i], pq[0], i, cb) | ||
|
||
var epr = ErrPartialResponse{} | ||
|
@@ -528,9 +546,6 @@ func (p *pool) fetchResourceWith(ctx context.Context, path string, cb DataCallba | |
// for now: reset i on partials so we also give them a chance to retry. | ||
i = -1 | ||
} | ||
if ce := ctx.Err(); ce != nil { | ||
return ce | ||
} | ||
} | ||
|
||
fetchDurationCarFailureMetric.Observe(float64(time.Since(carFetchStart).Milliseconds())) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is only a partial view of this, right? - because asks for
Has
andGetSize
also trigger parallel block triggers toGet
?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.
@willscott Yeah, just wanna focus on fetch for now.
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.
then lets not record the block api at all - misreporting will lead to confusion?
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.
@willscott
Fixed the instrumentation. We now record on the lower level block and car fetchBlockWith and fetchResourceWith instead of the public API for capturing accurate numbers.