From 66aeb467de80c92a099e49eaad6c25974c96f9cf Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 12 Oct 2017 19:08:18 +0200 Subject: pkg/ipc: don't send program padding to executor Currently we always send 2MB of data to executor in ipc_simple.go. Send only what's consumed by the program, and don't send the trailing zeros. Serialized programs usually take only few KBs. --- pkg/ipc/ipc_simple.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'pkg/ipc/ipc_simple.go') diff --git a/pkg/ipc/ipc_simple.go b/pkg/ipc/ipc_simple.go index 4c2ac6925..50dcce661 100644 --- a/pkg/ipc/ipc_simple.go +++ b/pkg/ipc/ipc_simple.go @@ -70,7 +70,8 @@ func (env *Env) Exec(opts *ExecOpts, p *prog.Prog) (output []byte, info []CallIn defer os.RemoveAll(dir) data := make([]byte, prog.ExecBufferSize) - if err := p.SerializeForExec(data, env.pid); err != nil { + n, err := p.SerializeForExec(data, env.pid) + if err != nil { err0 = err return } @@ -78,7 +79,7 @@ func (env *Env) Exec(opts *ExecOpts, p *prog.Prog) (output []byte, info []CallIn binary.Write(inbuf, binary.LittleEndian, uint64(env.config.Flags)) binary.Write(inbuf, binary.LittleEndian, uint64(opts.Flags)) binary.Write(inbuf, binary.LittleEndian, uint64(env.pid)) - inbuf.Write(data) + inbuf.Write(data[:n]) cmd := exec.Command(env.bin[0], env.bin[1:]...) cmd.Env = []string{} -- cgit mrf-deployment