Merge pull request #766 from harshavardhana/pr_out_make_channels_bufferred_upto_10000_for_cp_and_sync_to_fill_in_during_prepareurls_stage

Make channels bufferred upto 10000 for cp and sync to fill in during prepareURLs stage
This commit is contained in:
Harshavardhana
2015-06-10 17:33:25 -07:00
5 changed files with 12 additions and 14 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ lint:
cyclo:
@echo "Running $@:"
@test -z "$$(gocyclo -over 16 . | grep -v Godeps/_workspace/src/ | tee /dev/stderr)"
@test -z "$$(gocyclo -over 17 . | grep -v Godeps/_workspace/src/ | tee /dev/stderr)"
deadcode:
@echo "Running $@:"
+2 -2
View File
@@ -90,7 +90,7 @@ func doCopy(sourceURL string, targetURL string, bar *barSend) error {
// set up progress
newReader = bar.NewProxyReader(reader)
}
runtime.Gosched() // Yield more CPU
err = putTarget(targetURL, length, newReader)
if err != nil {
if !globalQuietFlag {
@@ -145,7 +145,7 @@ func doCopyCmd(sourceURLs []string, targetURL string, bar barSend) <-chan error
}
if !globalQuietFlag {
bar.Extend(cpURLs.SourceContent.Size)
lock.Up() // Let copy routine know that it is catch up.
lock.Up() // Let copy routine know that it has to catch up.
}
}
}(sourceURLs, targetURL)
+2 -2
View File
@@ -94,7 +94,7 @@ func doSync(sURLs syncURLs, bar *barSend) error {
// set up progress
newReader = bar.NewProxyReader(reader)
}
runtime.Gosched() // Yield more CPU
for err := range putTargets(targetURLs, length, newReader) {
if err != nil {
if !globalQuietFlag {
@@ -155,7 +155,7 @@ func runSyncCmd(ctx *cli.Context) {
}
if !globalQuietFlag {
bar.Extend(sURLs.SourceContent.Size)
lock.Up() // Let copy routine know that it is catch up.
lock.Up() // Let copy routine know that it has to catch up.
}
}
}(sourceURL, targetURLs)
+3 -5
View File
@@ -198,7 +198,7 @@ func prepareCopyURLsTypeB(sourceURL string, targetURL string) *cpURLs {
// SINGLE SOURCE - Type C: copy(d1..., d2) -> []copy(d1/f, d1/d2/f) -> []A
// prepareCopyRecursiveURLTypeC - prepares target and source URLs for copying.
func prepareCopyURLsTypeC(sourceURL, targetURL string) <-chan *cpURLs {
cpURLsCh := make(chan *cpURLs)
cpURLsCh := make(chan *cpURLs, 10000)
go func(sourceURL, targetURL string, cpURLsCh chan *cpURLs) {
defer close(cpURLsCh)
if !isURLRecursive(sourceURL) {
@@ -297,8 +297,7 @@ func prepareCopyURLsTypeC(sourceURL, targetURL string) <-chan *cpURLs {
// MULTI-SOURCE - Type D: copy([]f, d) -> []B
// prepareCopyURLsTypeD - prepares target and source URLs for copying.
func prepareCopyURLsTypeD(sourceURLs []string, targetURL string) <-chan *cpURLs {
cpURLsCh := make(chan *cpURLs)
cpURLsCh := make(chan *cpURLs, 10000)
go func(sourceURLs []string, targetURL string, cpURLsCh chan *cpURLs) {
defer close(cpURLsCh)
@@ -347,8 +346,7 @@ func prepareCopyURLsTypeD(sourceURLs []string, targetURL string) <-chan *cpURLs
// prepareCopyURLs - prepares target and source URLs for copying.
func prepareCopyURLs(sourceURLs []string, targetURL string) <-chan *cpURLs {
cpURLsCh := make(chan *cpURLs)
cpURLsCh := make(chan *cpURLs, 10000)
go func(sourceURLs []string, targetURL string, cpURLsCh chan *cpURLs) {
defer close(cpURLsCh)
switch guessCopyURLType(sourceURLs, targetURL) {
+4 -4
View File
@@ -78,7 +78,7 @@ func guessSyncURLType(sourceURL string, targetURLs []string) syncURLsType {
}
func prepareSyncURLsTypeA(sourceURL string, targetURLs []string) <-chan syncURLs {
syncURLsCh := make(chan syncURLs)
syncURLsCh := make(chan syncURLs, 10000)
go func() {
defer close(syncURLsCh)
var sURLs syncURLs
@@ -97,7 +97,7 @@ func prepareSyncURLsTypeA(sourceURL string, targetURLs []string) <-chan syncURLs
}
func prepareSyncURLsTypeB(sourceURL string, targetURLs []string) <-chan syncURLs {
syncURLsCh := make(chan syncURLs)
syncURLsCh := make(chan syncURLs, 10000)
go func() {
defer close(syncURLsCh)
var sURLs syncURLs
@@ -116,7 +116,7 @@ func prepareSyncURLsTypeB(sourceURL string, targetURLs []string) <-chan syncURLs
}
func prepareSyncURLsTypeC(sourceURL string, targetURLs []string) <-chan syncURLs {
syncURLsCh := make(chan syncURLs)
syncURLsCh := make(chan syncURLs, 10000)
go func() {
defer close(syncURLsCh)
if !isURLRecursive(sourceURL) {
@@ -214,7 +214,7 @@ func prepareSyncURLsTypeC(sourceURL string, targetURLs []string) <-chan syncURLs
// prepareCopyURLs - prepares target and source URLs for syncing.
func prepareSyncURLs(sourceURL string, targetURLs []string) <-chan syncURLs {
syncURLsCh := make(chan syncURLs)
syncURLsCh := make(chan syncURLs, 10000)
go func() {
defer close(syncURLsCh)
switch guessSyncURLType(sourceURL, targetURLs) {