aboutsummaryrefslogtreecommitdiff
path: root/guix-build-coordinator/agent-messaging
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-05-09 20:38:02 +0100
committerChristopher Baines <mail@cbaines.net>2020-05-09 20:38:02 +0100
commitab86dd62a77f59a73360bf85a2ba89405c352153 (patch)
tree97ca340c22a66aaa17eca79ad32540879afa3541 /guix-build-coordinator/agent-messaging
parent4f09a15fad7b4787ab7a3a14d1af42b6cda115b7 (diff)
downloadbuild-coordinator-ab86dd62a77f59a73360bf85a2ba89405c352153.tar
build-coordinator-ab86dd62a77f59a73360bf85a2ba89405c352153.tar.gz
Stop base64 encoding chunked requests
I'm not sure why I did this... but it's slower and more complex than just not base64 encoding the data.
Diffstat (limited to 'guix-build-coordinator/agent-messaging')
-rw-r--r--guix-build-coordinator/agent-messaging/http.scm48
1 files changed, 21 insertions, 27 deletions
diff --git a/guix-build-coordinator/agent-messaging/http.scm b/guix-build-coordinator/agent-messaging/http.scm
index 9e60b4a..40d6653 100644
--- a/guix-build-coordinator/agent-messaging/http.scm
+++ b/guix-build-coordinator/agent-messaging/http.scm
@@ -321,12 +321,10 @@ port. Also, the port used can be changed by passing the --port option.\n"
(lambda ()
(call-with-output-file output-file-name
(lambda (output-port)
- (let loop ((line (get-line body)))
- (unless (eof-object? line)
- (base64-decode line
- base64-alphabet
- output-port)
- (loop (get-line body))))))
+ (let loop ((bv (get-bytevector-some body)))
+ (unless (eof-object? bv)
+ (put-bytevector output-port bv)
+ (loop (get-bytevector-some body))))))
#t))
(no-content)
(render-json
@@ -348,48 +346,44 @@ port. Also, the port used can be changed by passing the --port option.\n"
(call-with-output-file output-file-name
(lambda (output-port)
(let ((start-time (current-time time-utc)))
- (let loop ((line (get-line body))
- (base64-characters-read 0)
- (last-progress-update-characters-read 0))
- (if (eof-object? line)
+ (let loop ((bv (get-bytevector-some body))
+ (bytes-read 0)
+ (last-progress-update-bytes-read 0))
+ (if (eof-object? bv)
(let* ((end-time (current-time time-utc))
(elapsed (time-difference end-time
start-time))
(seconds-elapsed
(+ (time-second elapsed)
- (/ (time-nanosecond elapsed) 1e9)))
- (bytes-transfered
- (* 3 (/ base64-characters-read 4))))
+ (/ (time-nanosecond elapsed) 1e9))))
(display
(simple-format
#f
"receiving ~A\n took ~A seconds\n data transfered: ~AMB\n speed (MB/s): ~A\n"
(basename output-file-name)
seconds-elapsed
- (rationalize (exact->inexact (/ bytes-transfered 1000000))
+ (rationalize (exact->inexact (/ bytes-read 1000000))
0.1)
- (rationalize (/ (/ bytes-transfered 1000000) seconds-elapsed)
+ (rationalize (/ (/ bytes-read 1000000) seconds-elapsed)
0.1))))
(begin
- (base64-decode line
- base64-alphabet
- output-port)
- (loop (get-line body)
- (+ base64-characters-read
- (string-length line))
- (if (> (- base64-characters-read
- last-progress-update-characters-read)
- 66666666) ; ~50MB in base64 characters
+ (put-bytevector output-port bv)
+ (loop (get-bytevector-some body)
+ (+ bytes-read
+ (bytevector-length bv))
+ (if (> (- bytes-read
+ last-progress-update-bytes-read)
+ 50000000) ; ~50MB
(begin
(display
(simple-format
#f "receiving ~A\n ~AMB read so far...\n"
(basename output-file-name)
- (rationalize (exact->inexact (/ (* 3 (/ base64-characters-read 4))
+ (rationalize (exact->inexact (/ bytes-read
1000000))
0.1)))
- base64-characters-read)
- last-progress-update-characters-read))))))))
+ bytes-read)
+ last-progress-update-bytes-read))))))))
#t))
(no-content)
(render-json