Simplify (?) arc upload code and make it more future-oriented
Summary: See discussion in D4968. This makes us run `file.uploadhash` calls in parallel, to slightly improve performance.
Test Plan:
Created a binary change in a commit:
$ head -c65535 /dev/urandom > a_random_file
$ git add .
$ git commit -m .
[master
32e4c0a] .
1 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a_random_file
Verified `arc diff` called `conduit.query`, then `file.uploadhash` (which we expect to fail; the file is new), then `file.upload`:
$ arc diff HEAD^ --only --trace
...
Uploading 1 files...
>>> [15] <conduit> conduit.query() <bytes = 157>
>>> [16] <http> http://local.aphront.com/api/conduit.query
<<< [16] <http> 111,500 us
<<< [15] <conduit> 112,169 us
>>> [17] <conduit> file.uploadhash() <bytes = 254>
>>> [18] <http> http://local.aphront.com/api/file.uploadhash
<<< [18] <http> 85,386 us
<<< [17] <conduit> 85,798 us
>>> [19] <conduit> file.upload() <bytes = 97009>
>>> [20] <http> http://local.aphront.com/api/file.upload
<<< [20] <http> 144,098 us
<<< [19] <conduit> 144,550 us
Uploaded 'a_random_file' (new).
Upload complete.
...
Created a new Differential diff:
Diff URI: http://local.aphront.com:8080/differential/diff/202/
Included changes:
A (bin) a_random_file
Created the same diff again, verified that we skip the data transfer this time:
$ arc diff HEAD^ --only --trace
...
Uploading 1 files...
>>> [15] <conduit> conduit.query() <bytes = 157>
>>> [16] <http> http://local.aphront.com/api/conduit.query
<<< [16] <http> 112,717 us
<<< [15] <conduit> 113,374 us
>>> [17] <conduit> file.uploadhash() <bytes = 254>
>>> [18] <http> http://local.aphront.com/api/file.uploadhash
<<< [18] <http> 95,545 us
<<< [17] <conduit> 95,921 us
Uploaded 'a_random_file' (new).
Upload complete.
...
Created a new Differential diff:
Diff URI: http://local.aphront.com:8080/differential/diff/203/
Included changes:
A (bin) a_random_file
Created a new commit which adds a new file and updates the exiting file:
$ head -c65535 /dev/urandom > another_file
$ head -c65535 /dev/urandom >> a_random_file
$ git add .
$ git commit -m .
[master
28f4fbd] .
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 another_file
Verified `arc diff` transfers one file by hash (old version of the first file) and two by data (new first file, new second file):
$ arc diff HEAD^ --only --trace
...
Uploading 3 files...
>>> [19] <conduit> conduit.query() <bytes = 157>
>>> [20] <http> http://local.aphront.com/api/conduit.query
<<< [20] <http> 114,825 us
<<< [19] <conduit> 115,517 us
>>> [21] <conduit> file.uploadhash() <bytes = 254>
>>> [22] <http> http://local.aphront.com/api/file.uploadhash
>>> [23] <conduit> file.uploadhash() <bytes = 254>
>>> [24] <http> http://local.aphront.com/api/file.uploadhash
>>> [25] <conduit> file.uploadhash() <bytes = 253>
>>> [26] <http> http://local.aphront.com/api/file.uploadhash
<<< [24] <http> 104,310 us
<<< [26] <http> 105,211 us
<<< [25] <conduit> 105,587 us
<<< [22] <http> 112,631 us
<<< [25] <conduit> 111,437 us
Uploaded 'a_random_file' (old).
<<< [25] <conduit> 111,678 us
>>> [27] <conduit> file.upload() <bytes = 193912>
>>> [28] <http> http://local.aphront.com/api/file.upload
>>> [29] <conduit> file.upload() <bytes = 97379>
>>> [30] <http> http://local.aphront.com/api/file.upload
<<< [28] <http> 153,126 us
<<< [29] <conduit> 161,180 us
Uploaded 'a_random_file' (new).
<<< [30] <http> 678,739 us
<<< [29] <conduit> 679,121 us
Uploaded 'another_file' (new).
Upload complete.
...
Created a new Differential diff:
Diff URI: http://local.aphront.com:8080/differential/diff/204/
Included changes:
M (bin) a_random_file
A (bin) another_file
Ran the same command again, verified three uploads by hash:
$ arc diff HEAD^ --only --trace
...
Uploading 3 files...
>>> [19] <conduit> conduit.query() <bytes = 157>
>>> [20] <http> http://local.aphront.com/api/conduit.query
<<< [20] <http> 117,058 us
<<< [19] <conduit> 117,792 us
>>> [21] <conduit> file.uploadhash() <bytes = 254>
>>> [22] <http> http://local.aphront.com/api/file.uploadhash
>>> [23] <conduit> file.uploadhash() <bytes = 254>
>>> [24] <http> http://local.aphront.com/api/file.uploadhash
>>> [25] <conduit> file.uploadhash() <bytes = 253>
>>> [26] <http> http://local.aphront.com/api/file.uploadhash
<<< [22] <http> 103,373 us
<<< [24] <http> 105,418 us
<<< [26] <http> 105,251 us
<<< [25] <conduit> 105,604 us
Uploaded 'a_random_file' (old).
<<< [25] <conduit> 105,844 us
Uploaded 'a_random_file' (new).
<<< [25] <conduit> 106,053 us
Uploaded 'another_file' (new).
Upload complete.
...
Created a new Differential diff:
Diff URI: http://local.aphront.com:8080/differential/diff/205/
Included changes:
M (bin) a_random_file
A (bin) another_file
$
Reviewers: kwadwon
Reviewed By: kwadwon
CC: aran
Maniphest Tasks: T2456
Differential Revision: https://secure.phabricator.com/D4993