-
Notifications
You must be signed in to change notification settings - Fork 105
Conversation
spec says: ``` ratio of peer responses after which speculation is used. Set to 1 to disable. speculation-threshold = 1 ``` However, code would only trigger after *more* than the threshold is met. example: 4 shardgroups. threshold = 0.75 imagine after 3 shardgroups have returned, you would expect the speculation to kick in. However, the logic would flow like this: percentReceived = 1 - (1/4) = 3/4 = 0.75 if percentReceived > speculationThreshold then speculate if 0.75 > 0.75 -> no speculation!. It would wait until another shard returns (in this case, until all shard groups return) also if threshold=1, bypass speculation logic more explicitly
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.
Minor comment.
// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Is pendingResponses
still worth anything? It seems superfluous. The current uses are:
- To drive the main loop (
for len(pendingResponses) > 0
) which could befor len(receivedResponses) < len(peerGroups)
- To decide upon who to speculate which could loop on
peerGroups
and continue if inrecievedResponses
.
I'm not sure it's worth the extra allocation.
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.
fixed, thanks
specCheckTicker := time.NewTicker(5 * time.Millisecond) | ||
var ticker *time.Ticker | ||
var tickChan <-chan time.Time | ||
if speculationThreshold != 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
// 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 comment
The 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 comment
The 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 comment
The 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.
i explained in depth in the commit message
(i generally try to make commit messages explain everything)
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.
Yes, that was my analysis as well 👍
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.
LGTM
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.
Nice!
No description provided.