Branch: refs/heads/master
  Home:   https://github.com/conformal/btcwire
  Commit: 9ee6a8aeb666d50684137e49b1dcc41b895690ff
      
https://github.com/conformal/btcwire/commit/9ee6a8aeb666d50684137e49b1dcc41b895690ff
  Author: Dave Collins <[email protected]>
  Date:   2013-11-06 (Wed, 06 Nov 2013)

  Changed paths:
    M blockheader.go
    M common.go
    M invvect.go
    M msggetblocks.go
    M msggetheaders.go

  Log Message:
  -----------
  Optimize writeElement.

This commit modifies the writeElement function to have a "fast path" which uses 
type
assertions for all of the types which btcwire write so the more expensive
reflection-based binary.Write can be avoided.

Also, this changes all cases that were writing raw ShaHash (32-byte) arrays 
(which
requires a stack copy) instead simply passing the pointer.

The following benchmark results show the results for serializing a block header
after these changes:

Before: BenchmarkWriteBlockHeader         500000              5566 ns/op
After:  BenchmarkWriteBlockHeader        1000000               991 ns/op

This is part of the ongoing effort to optimize serialization as noted in
conformal/btcd#27.



Reply via email to