Skip to content
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

Fast start the dns resolution ticker to improve first report latency. #1508

Merged
merged 1 commit into from
May 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions probe/appclient/app_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/rpc"
"sync"
Expand All @@ -20,6 +21,7 @@ import (
const (
initialBackoff = 1 * time.Second
maxBackoff = 60 * time.Second
dialTimeout = 5 * time.Second
)

// AppClient is a client to an app for dealing with controls.
Expand Down Expand Up @@ -64,6 +66,10 @@ func NewAppClient(pc ProbeConfig, hostname, target string, control xfer.ControlH
return nil, err
}

httpTransport.Dial = func(network, addr string) (net.Conn, error) {
return net.DialTimeout(network, addr, dialTimeout)
}

return &appClient{
ProbeConfig: pc,
quit: make(chan struct{}),
Expand Down
23 changes: 22 additions & 1 deletion probe/appclient/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,30 @@ const (
)

var (
tick = time.Tick
tick = fastStartTicker
)

// fastStartTicker is a ticker that 'ramps up' from 1 sec to duration.
func fastStartTicker(duration time.Duration) <-chan time.Time {
c := make(chan time.Time, 1)
go func() {
d := 1 * time.Second
for {
time.Sleep(d)
d = d * 2
if d > duration {
d = duration
}

select {
case c <- time.Now():
default:
}
}
}()
return c
}

type setter func(string, []string)

// Resolver is a thing that can be stopped...
Expand Down