Skip to content

Commit

Permalink
internal/compile: optimize the encoding (google#38)
Browse files Browse the repository at this point in the history
The simple gob encoding was showing up in profiles.
This change replaces it with a simple hand-written binary encoding
using strings and varints.  Strings and byte slices are allocated
in one contiguous block to reduce allocations.

The new encoder and decoder are about 5x faster with 10x fewer allocs.

+ benchmark
  • Loading branch information
adonovan authored Dec 3, 2018
1 parent 5eb2bff commit 29f9100
Show file tree
Hide file tree
Showing 6 changed files with 691 additions and 166 deletions.
2 changes: 1 addition & 1 deletion internal/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
const debug = false // TODO(adonovan): use a bitmap of options; and regexp to match files

// Increment this to force recompilation of saved bytecode files.
const Version = 3
const Version = 4

type Opcode uint8

Expand Down
Loading

0 comments on commit 29f9100

Please sign in to comment.