Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wire: only borrow/return binaryFreeList buffers at the message level #1426

Closed
wants to merge 52 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
8d005ab
wire/bench_test: report allocs in benchmarks
cfromknecht Jan 25, 2020
92351be
wire/bench: add witness block
cfromknecht Jan 25, 2020
e766de6
wire/common: optimize Read/WriteVarInt
cfromknecht Jan 25, 2020
a6da5b3
wire: introduce Read/WriteVarIntBuf to reuse buffers between invocations
cfromknecht Jan 25, 2020
35ac17f
wire/msgtx: use Read/WriteVarIntBuf in tx serialization
cfromknecht Jan 25, 2020
904f63c
wire/msgtx: reuse tx-level buffer for version and locktime
cfromknecht Jan 25, 2020
292e8f8
wire/common: add optimized Read/WriteVarBytesBuf
cfromknecht Jan 25, 2020
155d751
wire/msgtx: introduce optimized read/writeOutPointBuf
cfromknecht Jan 25, 2020
d24e5c7
wire/msgtx: introduce optimized writeTxInBuf
cfromknecht Jan 25, 2020
05b0ba0
wire/msgtx: use writeTxInBuf in txn encoding
cfromknecht Jan 25, 2020
ede651d
wire/msgtx: introduce optimized readScriptBuf
cfromknecht Apr 30, 2019
15d2e47
wire/msgtx: introduce optimized readTxInBuf
cfromknecht Apr 30, 2019
1f8a45b
wire/msgtx: use readTxInBuf in txn serialization
cfromknecht Jan 25, 2020
84d80e0
wire/msgtx: introduce optimized WriteTxOutBuf
cfromknecht Jan 25, 2020
ac4db9d
wire/msgtx: use WriteTxOutBuf in txn serialization
cfromknecht Jan 25, 2020
080cad5
wire/msgtx: introduce optimized readTxOutBuf
cfromknecht Jan 25, 2020
79976d0
wire/msgtx: use readTxOutBuf in txn serialization
cfromknecht Jan 25, 2020
56f1965
wire/msgtx: introduce optimized writeTxWitnessBuf
cfromknecht Jan 25, 2020
11fe696
wire/msgtx: use writeTxWitnessBuf in txn serialization
cfromknecht Jan 25, 2020
0f7d652
wire/msgtx: use readScriptBuf in txn serialization
cfromknecht Jan 25, 2020
84f1451
wire/bench_test: introduce optimized readBlockHeaderBuf
cfromknecht Jan 25, 2020
d733f6d
wire/blockheader: introduce optimized writeBlockHeaderBuf
cfromknecht Jan 25, 2020
ef0fd86
wire/invvect: add optimized readInvVectBuf and writeInvVectBuf
cfromknecht Jan 25, 2020
0e1207f
wire/msggetblocks: optimize by reusing small buffer
cfromknecht Jan 25, 2020
db91c07
wire/msgblock: use only one small buffer per block encode/decode
cfromknecht Jan 25, 2020
549d33f
wire/msgblock: optimize DeserializeTxLoc by reusing small buffers
cfromknecht Jan 25, 2020
b8f2f38
wire/msggetheaders: optimize serialization by reusing small buffers
cfromknecht Jan 25, 2020
0645d64
wire/msgheaders: optimize serialization by reusing small buffers
cfromknecht Jan 25, 2020
8f0a986
wire/msggetcfheaders: use single small buffer for encode/decode
cfromknecht Jan 25, 2020
73693d9
wire/msgcfheaders: optimize encode/decode by using one small buffer
cfromknecht Jan 25, 2020
4b4dfaa
wire/msggetcfcheckpt: optimize by removing read/writeElement
cfromknecht Jan 25, 2020
cdd28f0
wire/msgcfcheckpt: optimize serialization by reusing small buffers
cfromknecht Jan 25, 2020
22cdfc2
wire/msginv: optimize by reusing small buffers
cfromknecht Jan 25, 2020
10c5459
wire/msggetdata: optimize serialization by reusing small buffers
cfromknecht Jan 25, 2020
6d3d4b2
wiree/msggetcfilters: optimize serialization by reusing small buffers
cfromknecht Jan 25, 2020
af9fdaa
wire/msgcfilter: optimize serialization by reusing small buffers
cfromknecht Jan 25, 2020
a1c1620
wire/msgnotfound: optimize serialization by reusing small buffers
cfromknecht Jan 25, 2020
33c8877
wire/invvect: remove unused readInvVect and writeInvVect
cfromknecht Jan 25, 2020
6147d8b
wire/common: add optimized writeVarStrBuf an readVarStrBuf
cfromknecht Jan 25, 2020
49aba92
wire/msgreject: optimize serialization by reusing small buffers
cfromknecht Jan 25, 2020
518fa70
wire/netaddress: add optimiezed read/writeNetAddressBuf
cfromknecht Jan 25, 2020
f4388ef
wire/msgmerkleblock: optimize serialization by reusing small buffers
cfromknecht Jan 25, 2020
a5affa7
wire/msgping: remove usage for read/writeElement
cfromknecht Jan 25, 2020
08c24c9
wire/msgpong: remove usage of read/writeElement
cfromknecht Jan 25, 2020
b92f8e2
wire/msgtx: remove unused writeTxWitness
cfromknecht Jan 25, 2020
0b121ec
wire/msgtx: remove unused readTxOut
cfromknecht Jan 25, 2020
055a6a8
wire/msgtx: remove unused writeTxIn
cfromknecht Jan 25, 2020
0b67c05
wire/msgtx: remove unused readTxIn
cfromknecht Jan 25, 2020
49ac379
wire/msgtx: remove unused readScript
cfromknecht Jan 25, 2020
512571b
wire/msgtx: remove unused read/writeOutPoint
cfromknecht Jan 25, 2020
e7ed275
wire/msgtx: use tx-level script slab
cfromknecht Jan 25, 2020
86ba486
wire/msgblock+msgtx: user block-level script slab
cfromknecht Jan 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wire/msgcfilter: optimize serialization by reusing small buffers
  • Loading branch information
cfromknecht committed Feb 5, 2021
commit af9fdaaae1e632690a850cd11654b0034c760606
28 changes: 18 additions & 10 deletions wire/msgcfilter.go
Original file line number Diff line number Diff line change
@@ -38,20 +38,24 @@ type MsgCFilter struct {
// This is part of the Message interface implementation.
func (msg *MsgCFilter) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding) error {
// Read filter type
err := readElement(r, &msg.FilterType)
if err != nil {
buf := binarySerializer.Borrow()
if _, err := io.ReadFull(r, buf[:1]); err != nil {
binarySerializer.Return(buf)
return err
}
msg.FilterType = FilterType(buf[0])

// Read the hash of the filter's block
err = readElement(r, &msg.BlockHash)
if err != nil {
if _, err := io.ReadFull(r, msg.BlockHash[:]); err != nil {
binarySerializer.Return(buf)
return err
}

// Read filter data
msg.Data, err = ReadVarBytes(r, pver, MaxCFilterDataSize,
var err error
msg.Data, err = ReadVarBytesBuf(r, pver, buf, MaxCFilterDataSize,
"cfilter data")
binarySerializer.Return(buf)
return err
}

@@ -65,17 +69,21 @@ func (msg *MsgCFilter) BtcEncode(w io.Writer, pver uint32, _ MessageEncoding) er
return messageError("MsgCFilter.BtcEncode", str)
}

err := writeElement(w, msg.FilterType)
if err != nil {
buf := binarySerializer.Borrow()
buf[0] = byte(msg.FilterType)
if _, err := w.Write(buf[:1]); err != nil {
binarySerializer.Return(buf)
return err
}

err = writeElement(w, msg.BlockHash)
if err != nil {
if _, err := w.Write(msg.BlockHash[:]); err != nil {
binarySerializer.Return(buf)
return err
}

return WriteVarBytes(w, pver, msg.Data)
err := WriteVarBytesBuf(w, pver, msg.Data, buf)
binarySerializer.Return(buf)
return err
}

// Deserialize decodes a filter from r into the receiver using a format that is