copy using bytes pools

Vendor and use docker/pkg/pools.
pools are used to lower the number of memory allocations and reuse buffers when
processing large streams operations..

The use of pools.Copy avoids io.Copy's internal buffer allocation.
This commit replaces io.Copy with pools.Copy to avoid the allocation of
buffers in io.Copy.

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2017-06-10 18:33:35 +02:00
parent 0b2f6b5354
commit b211061016
No known key found for this signature in database
GPG key ID: B2BEAD150DE936B9
4 changed files with 124 additions and 5 deletions

View file

@ -10,6 +10,7 @@ import (
"syscall"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/pkg/pools"
"github.com/kubernetes-incubator/cri-o/oci"
"github.com/kubernetes-incubator/cri-o/utils"
"golang.org/x/net/context"
@ -108,7 +109,7 @@ func redirectResponseToOutputStream(tty bool, outputStream, errorStream io.Write
}
var err error
if tty {
_, err = io.Copy(outputStream, conn)
_, err = pools.Copy(outputStream, conn)
} else {
// TODO
}