Skip to content

Commit

Permalink
mirror: Fix performance problem by using bufferred channels.
Browse files Browse the repository at this point in the history
The problem was that statusCh, queues were all waiting on the
select for too long. This is the nature of things in Go.

Using bufferred channel increases the performance as expected.

Fixes #1908
  • Loading branch information
harshavardhana committed Dec 5, 2016
1 parent ce9d706 commit f4d9f5e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/cp-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func doCopySession(session *sessionV8) {
}

// Wait on status of doCopy() operation.
var statusCh = make(chan URLs)
var statusCh = make(chan URLs, 10000)

// Add a wait group.
var wg = new(sync.WaitGroup)
Expand Down
4 changes: 2 additions & 2 deletions cmd/mirror-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,8 @@ func newMirrorSession(session *sessionV8) *mirrorSession {
trapCh: signalTrap(os.Interrupt, syscall.SIGTERM),
sessionV8: session,

statusCh: make(chan URLs),
harvestCh: make(chan URLs),
statusCh: make(chan URLs, 10000),
harvestCh: make(chan URLs, 10000),
errorCh: make(chan *probe.Error),

watcher: NewWatcher(session.Header.When),
Expand Down
2 changes: 1 addition & 1 deletion cmd/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type Queue struct {
// NewQueue creates a new queue
func NewQueue() *Queue {
return &Queue{
idleCh: make(chan interface{}),
idleCh: make(chan interface{}, 10000),
closed: false,
}
}
Expand Down

0 comments on commit f4d9f5e

Please sign in to comment.