I run a f1-macro gcloud machine with tiny 600M memory with go 1.6
try to read a ~2G text file from Google cloud storage line by line, but not
preserve each line.

So the setting become:
- HTTP2 enabled
- Trying to read content > main memory size, but not preserving them
- Fast network
- Slow reader

I expect stable memory usage as I read from local file system, but I got
OOM with stack attached at end of message.
gcsfuse (https://github.com/GoogleCloudPlatform/gcsfuse) has the same
When disable HTTP2 (in my case, I switched to go 1.5) things work fine,
memory consumption remain stable.

The problem seems to be in http2 client behavior, it use a separate
goroutine to read content into a bytes.Buffer,
without coordination with readers, when you have a really fast network but
slow reader, reader would not be able
to catch up, bytes.Buffer would never have a chance to reclaim memory

Should we consider it a http2 client's bug? (lack of synchronization) or
any suggestions with workaround, except to not use http2?


OOM stack

goroutine 23 [running]:
         /home/yuheng/opt/go/src/runtime/asm_amd64.s:245 fp=0xc820047a38 sp=0xc820047a30
runtime.mallocgc(0xf620000, 0x73d040, 0x1, 0x7fc59d07bcd8)
         /home/yuheng/opt/go/src/runtime/malloc.go:665 +0x9eb fp=0xc820047b10 sp=0xc820047a38
runtime.newarray(0x73d040, 0xf620000, 0xc820047bb0)
         /home/yuheng/opt/go/src/runtime/malloc.go:798 +0xc9 fp=0xc820047b50 sp=0xc820047b10
runtime.makeslice(0x72e820, 0xf620000, 0xf620000, 0x0, 0x0, 0x0)
         /home/yuheng/opt/go/src/runtime/slice.go:32 +0x165 fp=0xc820047ba0 sp=0xc820047b50
bytes.makeSlice(0xf620000, 0x0, 0x0, 0x0)
         /home/yuheng/opt/go/src/bytes/buffer.go:198 +0x64 fp=0xc820047bf0 sp=0xc820047ba0
bytes.(*Buffer).grow(0xc82017ea80, 0x4000, 0xc820047cf0)
         /home/yuheng/opt/go/src/bytes/buffer.go:106 +0x282 fp=0xc820047c98 sp=0xc820047bf0
bytes.(*Buffer).Write(0xc82017ea80, 0xc8201c4000, 0x4000, 0x4000, 0x4b7ae0, 0x0, 0x0)
         /home/yuheng/opt/go/src/bytes/buffer.go:134 +0x4b fp=0xc820047cf0 sp=0xc820047c98
net/http.(*http2pipe).Write(0xc8203b8ca0, 0xc8201c4000, 0x4000, 0x4000, 0x0, 0x0, 0x0)
         /home/yuheng/opt/go/src/net/http/h2_bundle.go:2397 +0x1c1 fp=0xc820047d68 sp=0xc820047cf0
net/http.(*http2clientConnReadLoop).processData(0xc820390320, 0xc820997d70, 0x0, 0x0)
         /home/yuheng/opt/go/src/net/http/h2_bundle.go:5857 +0x35e fp=0xc820047de8 sp=0xc820047d68
net/http.(*http2clientConnReadLoop).run(0xc820390320, 0x0, 0x0)
         /home/yuheng/opt/go/src/net/http/h2_bundle.go:5607 +0x4db fp=0xc820047f20 sp=0xc820047de8
         /home/yuheng/opt/go/src/net/http/h2_bundle.go:5544 +0x162 fp=0xc820047f98 sp=0xc820047f20
         /home/yuheng/opt/go/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc820047fa0 sp=0xc820047f98
created by net/http.(*http2Transport).NewClientConn
         /home/yuheng/opt/go/src/net/http/h2_bundle.go:4975 +0xd94

You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
postedMay 9, '16 at 5:34a
activeMay 9, '16 at 5:34a

1 user in discussion

Kuangyuheng: 1 post



site design / logo © 2021 Grokbase