Improve performance (#92)

* Update performance

* Turn off prometheus

* Add gbc

* Remove MAXPROCS 1

* Add updte config

* Update util + docker ignore
This commit is contained in:
giongto35 2019-09-30 02:17:38 +08:00 committed by GitHub
parent 6bf2db51ac
commit cf5007110e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 23 additions and 20 deletions

7
.dockerignore vendored
View file

@ -1 +1,6 @@
games
*/assets/games/*
.git
.gitignore
LICENSE
VERSION
docs

5
.gitignore vendored
View file

@ -58,4 +58,7 @@ turnserver.conf
### Ignore build artifact directory
bin/
.coverage.out
_output/
_output/
./build
.dockerignore

View file

@ -23,6 +23,7 @@ const NumKeys = 10
var FileTypeToEmulator = map[string]string{
"gba": "gba",
"gbc": "gba",
"cue": "pcsx",
"zip": "mame",
"nes": "nes",

View file

@ -62,12 +62,15 @@ type naEmulator struct {
}
var NAEmulator *naEmulator
var outputImg *image.RGBA
// NAEmulator implements CloudEmulator interface based on NanoArch(golang RetroArch)
func NewNAEmulator(etype string, roomID string, imageChannel chan<- *image.RGBA, audioChannel chan<- float32, inputChannel <-chan int) *naEmulator {
meta := config.EmulatorConfig[etype]
ewidth = meta.Width
eheight = meta.Height
// outputImg is tmp img used for decoding and reuse in encoding flow
outputImg = image.NewRGBA(image.Rect(0, 0, ewidth, eheight))
return &naEmulator{
meta: meta,

View file

@ -153,7 +153,6 @@ func to8888Image(data unsafe.Pointer, bytes []byte, bytesPerRow int, inputWidth,
scaleWidth := float64(ewidth) / float64(inputWidth)
scaleHeight := float64(eheight) / float64(inputHeight)
image := image.NewRGBA(image.Rect(0, 0, ewidth, eheight))
for y := 0; y < inputHeight; y++ {
for x := 0; x < bytesPerRow; x++ {
xx := int(float64(x) * scaleWidth)
@ -164,7 +163,7 @@ func to8888Image(data unsafe.Pointer, bytes []byte, bytesPerRow int, inputWidth,
r8 := bytes[seek+2]
a8 := bytes[seek+3]
image.Set(xx, yy, color.RGBA{byte(r8), byte(g8), byte(b8), byte(a8)})
outputImg.Set(xx, yy, color.RGBA{byte(r8), byte(g8), byte(b8), byte(a8)})
}
seek += 4
@ -172,7 +171,7 @@ func to8888Image(data unsafe.Pointer, bytes []byte, bytesPerRow int, inputWidth,
}
// TODO: Resize Image
return image
return outputImg
}
func to565Image(data unsafe.Pointer, bytes []byte, bytesPerRow int, inputWidth, inputHeight int) *image.RGBA {
@ -182,7 +181,6 @@ func to565Image(data unsafe.Pointer, bytes []byte, bytesPerRow int, inputWidth,
scaleWidth := float64(ewidth) / float64(inputWidth)
scaleHeight := float64(eheight) / float64(inputHeight)
image := image.NewRGBA(image.Rect(0, 0, ewidth, eheight))
for y := 0; y < inputHeight; y++ {
for x := 0; x < bytesPerRow; x++ {
xx := int(float64(x) * scaleWidth)
@ -198,7 +196,7 @@ func to565Image(data unsafe.Pointer, bytes []byte, bytesPerRow int, inputWidth,
g8 := (g6*255 + 31) / 63
r8 := (r5*255 + 15) / 31
image.Set(int(float64(xx)*scaleWidth), int(float64(yy)*scaleHeight), color.RGBA{byte(r8), byte(g8), byte(b8), 255})
outputImg.Set(int(float64(xx)*scaleWidth), int(float64(yy)*scaleHeight), color.RGBA{byte(r8), byte(g8), byte(b8), 255})
}
seek += 2
@ -206,7 +204,7 @@ func to565Image(data unsafe.Pointer, bytes []byte, bytesPerRow int, inputWidth,
}
// TODO: Resize Image
return image
return outputImg
}
//export coreInputPoll

View file

@ -18,9 +18,10 @@ func NewDefaultConfig() Config {
Port: 8800,
MonitoringConfig: monitoring.ServerMonitoringConfig{
Port: 6601,
URLPrefix: "/overlord",
MetricEnabled: true,
Port: 6601,
URLPrefix: "/overlord",
MetricEnabled: false,
ProfilingEnabled: false,
},
}
}

View file

@ -88,8 +88,5 @@ func savePath(hash string) string {
// Actually Android is only supporting VP8 but H264 has better encoding performance
// TODO: Better use useragent attribute from frontend
func GetVideoEncoder(isMobile bool) string {
if isMobile == true {
return config.CODEC_VP8
}
return config.CODEC_H264
return config.CODEC_VP8
}

View file

@ -10,7 +10,6 @@ import (
"github.com/giongto35/cloud-game/pkg/monitoring"
"github.com/golang/glog"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
type OverWorker struct {
@ -75,10 +74,6 @@ func (o *OverWorker) initializeWorker() {
}
l.Close()
if port == 9000 {
// only turn on metric for the first worker to avoid overlap
http.Handle("/metrics", promhttp.Handler())
}
// echo endpoint is where user will request to test latency
http.HandleFunc("/echo", func(w http.ResponseWriter, r *http.Request) {