Description
What version of Go are you using (go version
)?
$ go version go version go1.11.4 windows/amd64
Does this issue reproduce with the latest release?
I tried 1.9.7 and 1.10.7 with the same results. I assume 1.11.5 is the same as there are no new relevant commits.
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\micro\AppData\Local\go-build set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOOS=windows set GOPATH=C:\Users\micro\go set GOPROXY= set GORACE= set GOROOT=C:\Go set GOTMPDIR= set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64 set GCCGO=gccgo set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD= set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\micro\AppData\Local\Temp\go-build335086354=/tmp/go-build -gno-record-gcc-switches
What did you do?
I have a 4.2ghz i7 iMac, which is running macOS 10.14.2
On the iMac, I'm also using VirtualBox to run a VM with Windows 10 Pro 10.0.17134 Build 17134
I have a 1.65GB video file named stream.mpg
that exists both on my macOS host and inside the VM.
I'm using the following go program to serve up that file via http:
package main
import (
"net/http"
)
func main() {
http.HandleFunc("/stream.mpg", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "stream.mpg")
})
http.ListenAndServe(":9000", nil)
}
I'm running this server both on macOS and Windows. The macOS host is 10.0.1.10
and the Windows VM is 10.0.1.20
I observe the following results when using curl to download the file to measure download speed/time. Note the "Average DLoad" and "Time Total" columns in the middle. Each result below is the best of three runs. (The first result not shown is usually much slower, as the file is not memory mapped into the fs cache yet).
Windows <- Windows
tmm1@windows $ curl.exe -o nul http://10.0.1.20:9000/stream.mpg
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1651M 100 1651M 0 0 550M 0 0:00:03 0:00:03 --:--:-- ---
Windows <- macOS
tmm1@windows $ curl.exe -o nul http://10.0.1.10:9000/stream.mpg
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1651M 100 1651M 0 0 550M 0 0:00:03 0:00:03 --:--:-- ---
macOS <- macOS
tmm1@macos $ curl -o /dev/null http://10.0.1.10:9000/stream.mpg
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1651M 100 1651M 0 0 1643M 0 0:00:01 0:00:01 --:--:-- ---
macOS <- Windows
tmm1@macos $ curl -o /dev/null http://10.0.1.20:9000/stream.mpg
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1651M 100 1651M 0 0 143M 0 0:00:11 0:00:11 --:--:-- ---
What did you expect to see?
Similar speeds when serving the file from Windows and macOS.
What did you see instead?
When running the server on macOS, the local host can download 1.65GB in 1s, and the Windows VM can download the file in 3s.
When running the server on Windows, the local VM can download 1.65GB in 3s, but the host takes over 11s to fetch the file and maxes out at 145Mbps.
I've observed the same behavior with physical hosts, and the VMs in this test were only setup to remove any network hardware from the test.