-
Notifications
You must be signed in to change notification settings - Fork 105
Speculative execution fixes #979
Changes from 5 commits
e3c47c6
af8923b
8d06e78
dbb9bf6
6690299
3428869
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -306,7 +306,7 @@ func (s *Server) peerQuery(ctx context.Context, data cluster.Traceable, name, pa | |
// across the cluster, except to the local peer. If any peer fails requests to | ||
// other peers are aborted. If enough peers have been heard from (based on | ||
// speculation-threshold configuration), and we are missing the others, try to | ||
// speculatively query other members of the shard group. | ||
// speculatively query each other member of each shard group. | ||
// ctx: request context | ||
// data: request to be submitted | ||
// name: name to be used in logging & tracing | ||
|
@@ -363,7 +363,13 @@ func (s *Server) peerQuerySpeculative(ctx context.Context, data cluster.Traceabl | |
|
||
result := make(map[string]PeerResponse) | ||
|
||
specCheckTicker := time.NewTicker(5 * time.Millisecond) | ||
var ticker *time.Ticker | ||
var tickChan <-chan time.Time | ||
if speculationThreshold != 1 { | ||
ticker = time.NewTicker(5 * time.Millisecond) | ||
tickChan = ticker.C | ||
defer ticker.Stop() | ||
} | ||
|
||
for len(pendingResponses) > 0 { | ||
select { | ||
|
@@ -382,12 +388,12 @@ func (s *Server) peerQuerySpeculative(ctx context.Context, data cluster.Traceabl | |
delete(pendingResponses, resp.shardGroup) | ||
delete(originalPeers, resp.data.peer.GetName()) | ||
|
||
case <-specCheckTicker.C: | ||
case <-tickChan: | ||
// Check if it's time to speculate! | ||
percentReceived := 1 - (float64(len(pendingResponses)) / float64(len(peerGroups))) | ||
if percentReceived > speculationThreshold { | ||
percentReceived := float64(len(receivedResponses)) / float64(len(peerGroups)) | ||
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. Is
I'm not sure it's worth the extra allocation. 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. fixed, thanks 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. that's changing the logic, but it's actually making it correct, so that's good. 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. What's the change in logic? 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. this particular line should not change logic. but the line below it does. 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. Yes, that was my analysis as well 👍 |
||
if percentReceived >= speculationThreshold { | ||
// kick off speculative queries to other members now | ||
specCheckTicker.Stop() | ||
ticker.Stop() | ||
speculativeAttempts.Inc() | ||
for shardGroup := range pendingResponses { | ||
eligiblePeers := peerGroups[shardGroup][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.
that's nice. so the ticker doesn't even get instantiated if
speculationThreshold == 1