2013-06-04 14 views
1

我在具有25個4gb json文件的目錄(我也在使用-z選項進行壓縮)上並行運行gsutil cp命令(使用-m選項)。限制並行文件到cp的數量

gsutil -m cp -z json -R dir_with_4g_chunks gs://my_bucket/ 

當我運行它時,它將打印出終端,它正在複製除一個文件以外的所有文件。我的意思是,它打印每個文件的這些行之一:

Copying file://dir_with_4g_chunks/a_4g_chunk [Content-Type=application/octet-stream]... 

一旦其中的一個傳送完成,它說,它會被複制的最後一個文件。

這樣做的結果是,有一個文件,僅啓動時別人的一個複印完畢後只複製,顯著放緩過程

有沒有我可以上傳文件的數量限制-m選項?這是可配置在boto配置文件?

回答

5

the description of the -m option

的gsutil進行使用 多線程和多處理的組合來指定的操作,使用多個線程和由parallel_thread_count和 parallel_process_count值確定 處理器中所設置的boto配置文件。您可能想要嘗試使用這些值,因爲最佳值可以根據許多因素變化,包括網絡速度,CPU數量,可用內存和 。

如果你看一看.boto檔案,你會看到這樣產生的評論:

# 'parallel_process_count' and 'parallel_thread_count' specify the number 
# of OS processes and Python threads, respectively, to use when executing 
# operations in parallel. The default settings should work well as configured, 
# however, to enhance performance for transfers involving large numbers of 
# files, you may experiment with hand tuning these values to optimize 
# performance for your particular system configuration. 
# MacOS and Windows users should see 
# https://github.com/GoogleCloudPlatform/gsutil/issues/77 before attempting 
# to experiment with these values. 
#parallel_process_count = 12 
#parallel_thread_count = 10 

我猜你是在Windows或Mac,因爲非默認值-Linux機器有24個線程和1個進程。這會導致先複製24個文件,然後再複製最後1個文件。嘗試嘗試增加這些值以一次傳輸全部25個文件。

5

我無法找到我的Mac上的文件.boto(按照上述jterrace的答案),而不是我指定使用-o開關這些值:

gsutil -m -o "Boto:parallel_thread_count=4" cp directory1/* gs://my-bucket/ 

這似乎控制率轉讓。