From a7e4a49fae26bf52b4b8f26aeebc50d947dc1abc Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 20 Jan 2017 23:55:25 +0100 Subject: all: spot optimizations A bunch of spot optmizations after cpu/memory profiling: 1. Optimize hot-path coverage comparison in fuzzer. 2. Don't allocate and copy serialized program, serialize directly into shmem. 3. Reduce allocations during parsing of output shmem (encoding/binary sucks). 4. Don't allocate and copy coverage arrays, refer directly to the shmem region (we are not going to mutate them). 5. Don't validate programs outside of tests, validation allocates tons of memory. 6. Replace the choose primitive with simpler switches. Choose allocates fullload of memory (for int, func, and everything the func refers). 7. Other minor optimizations. --- prog/encoding.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'prog/encoding.go') diff --git a/prog/encoding.go b/prog/encoding.go index b04f667ba..8c7c1674a 100644 --- a/prog/encoding.go +++ b/prog/encoding.go @@ -27,11 +27,9 @@ func (p *Prog) String() string { } func (p *Prog) Serialize() []byte { - /* - if err := p.validate(); err != nil { - panic("serializing invalid program") - } - */ + if err := p.validate(); err != nil { + panic("serializing invalid program") + } buf := new(bytes.Buffer) vars := make(map[*Arg]int) varSeq := 0 -- cgit mrf-deployment