提交 02792054 作者: Jeromy

more memory tweaks

上级 9b1c99e9
...@@ -36,9 +36,11 @@ func bindDuplexNoCopy(a, b pipes.Duplex) { ...@@ -36,9 +36,11 @@ func bindDuplexNoCopy(a, b pipes.Duplex) {
} }
} }
var globuf = make([]byte, 4*1024*1024)
func bindDuplexWithCopy(a, b pipes.Duplex) { func bindDuplexWithCopy(a, b pipes.Duplex) {
dup := func(byt []byte) []byte { dup := func(byt []byte) []byte {
n := make([]byte, len(byt)) n := globuf[:len(byt)]
copy(n, byt) copy(n, byt)
return n return n
} }
......
...@@ -8,7 +8,7 @@ import ( ...@@ -8,7 +8,7 @@ import (
var log = util.Logger("chunk") var log = util.Logger("chunk")
var DefaultSplitter = &SizeSplitter{Size: 1024 * 512} var DefaultSplitter = &SizeSplitter{Size: 1024 * 256}
type BlockSplitter interface { type BlockSplitter interface {
Split(r io.Reader) chan []byte Split(r io.Reader) chan []byte
......
...@@ -22,7 +22,7 @@ const ( ...@@ -22,7 +22,7 @@ const (
ChanBuffer = 10 ChanBuffer = 10
// MaxMessageSize is the size of the largest single message // MaxMessageSize is the size of the largest single message
MaxMessageSize = 1 << 21 // 4 MB MaxMessageSize = 1 << 20
// HandshakeTimeout for when nodes first connect // HandshakeTimeout for when nodes first connect
HandshakeTimeout = time.Second * 5 HandshakeTimeout = time.Second * 5
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论