diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-04-15 12:36:20 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-04-15 13:23:33 +0000 |
| commit | 80ce88419762e4342971463033802fea7cdb2973 (patch) | |
| tree | e522a76cfc92dfe1c31470f2993923737d641d3d /prog/encodingexec.go | |
| parent | 416332e39df7236896d0d13bebcc7bb13105c0a4 (diff) | |
prog: use leb128 for exec encoding
Switch from uint64 to leb128 encoding for integers.
This almost more than halves serialized size:
- exec sizes: 10%:2160 50%:4792 90%:14288
+ exec sizes: 10%:597 50%:1438 90%:7145
and makes it smaller than the text serialization:
text sizes: 10%:837 50%:1591 90%:10156
Diffstat (limited to 'prog/encodingexec.go')
| -rw-r--r-- | prog/encodingexec.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/prog/encodingexec.go b/prog/encodingexec.go index 44a49fc58..2c13d452c 100644 --- a/prog/encodingexec.go +++ b/prog/encodingexec.go @@ -20,6 +20,7 @@ package prog import ( + "encoding/binary" "errors" "fmt" "reflect" @@ -251,8 +252,8 @@ func (w *execContext) write(v uint64) { w.eof = true return } - HostEndian.PutUint64(w.buf, v) - w.buf = w.buf[8:] + n := binary.PutVarint(w.buf, int64(v)) + w.buf = w.buf[n:] } func (w *execContext) writeArg(arg Arg) { |
