Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Speculative execution fixes #979

Merged
merged 6 commits into from
Aug 7, 2018
Merged

Speculative execution fixes #979

merged 6 commits into from
Aug 7, 2018

Conversation

Dieterbe
Copy link
Contributor

@Dieterbe Dieterbe commented Aug 7, 2018

No description provided.

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
@Dieterbe Dieterbe changed the title Speculative fixes Speculative execution fixes Aug 7, 2018
@Dieterbe Dieterbe requested a review from shanson7 August 7, 2018 01:06
Copy link
Collaborator

@shanson7 shanson7 left a 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))
Copy link
Collaborator

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:

  1. To drive the main loop (for len(pendingResponses) > 0) which could be for len(receivedResponses) < len(peerGroups)
  2. To decide upon who to speculate which could loop on peerGroups and continue if in recievedResponses.

I'm not sure it's worth the extra allocation.

Copy link
Contributor Author

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 {
Copy link
Contributor

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))
Copy link
Contributor

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.

Copy link
Collaborator

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?

Copy link
Contributor Author

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)

Copy link
Collaborator

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 👍

Copy link
Contributor

@replay replay left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@shanson7 shanson7 left a comment

Choose a reason for hiding this comment

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

Nice!

@Dieterbe Dieterbe merged commit 8d392cb into master Aug 7, 2018
@Dieterbe Dieterbe deleted the speculative-fixes branch September 18, 2018 08:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants