aboutsummaryrefslogtreecommitdiffstats
path: root/csource
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-01-20 23:55:25 +0100
committerDmitry Vyukov <dvyukov@google.com>2017-01-20 23:55:25 +0100
commita7e4a49fae26bf52b4b8f26aeebc50d947dc1abc (patch)
tree03ccdac553f003b5b389587ebb5a74d4b8091865 /csource
parenta8632569bf8339f5fa468f99493d4d825db2cb12 (diff)
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.
Diffstat (limited to 'csource')
-rw-r--r--csource/csource.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/csource/csource.go b/csource/csource.go
index 316ac9297..08ccae03a 100644
--- a/csource/csource.go
+++ b/csource/csource.go
@@ -30,7 +30,10 @@ type Options struct {
}
func Write(p *prog.Prog, opts Options) ([]byte, error) {
- exec := p.SerializeForExec(0)
+ exec := make([]byte, prog.ExecBufferSize)
+ if err := p.SerializeForExec(exec, 0); err != nil {
+ return nil, fmt.Errorf("failed to serialize program: %v", err)
+ }
w := new(bytes.Buffer)
fmt.Fprint(w, "// autogenerated by syzkaller (http://github.com/google/syzkaller)\n\n")