You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
4.9 KiB

internal/libs/protoio: optimize MarshalDelimited by plain byteslice allocations+sync.Pool (#7325) Noticed in profiles that invoking *VoteSignBytes always created a bytes.Buffer, then discarded it inside protoio.MarshalDelimited. I dug further and examined the call paths and noticed that we unconditionally create the bytes.Buffer, even though we might have proto messages (in the common case) that implement MarshalTo([]byte), and invoked varintWriter. Instead by inlining this case, we skip a bunch of allocations and CPU cycles, which then reflects properly on all calling functions. Here are the benchmark results: ```shell $ benchstat before.txt after.txt name old time/op new time/op delta types.VoteSignBytes-8 705ns ± 3% 573ns ± 6% -18.74% (p=0.000 n=18+20) types.CommitVoteSignBytes-8 8.15µs ± 9% 6.81µs ± 4% -16.51% (p=0.000 n=20+19) protoio.MarshalDelimitedWithMarshalTo-8 788ns ± 8% 772ns ± 3% -2.01% (p=0.050 n=20+20) protoio.MarshalDelimitedNoMarshalTo-8 989ns ± 4% 845ns ± 2% -14.51% (p=0.000 n=20+18) name old alloc/op new alloc/op delta types.VoteSignBytes-8 792B ± 0% 600B ± 0% -24.24% (p=0.000 n=20+20) types.CommitVoteSignBytes-8 9.52kB ± 0% 7.60kB ± 0% -20.17% (p=0.000 n=20+20) protoio.MarshalDelimitedNoMarshalTo-8 808B ± 0% 440B ± 0% -45.54% (p=0.000 n=20+20) name old allocs/op new allocs/op delta types.VoteSignBytes-8 13.0 ± 0% 10.0 ± 0% -23.08% (p=0.000 n=20+20) types.CommitVoteSignBytes-8 140 ± 0% 110 ± 0% -21.43% (p=0.000 n=20+20) protoio.MarshalDelimitedNoMarshalTo-8 10.0 ± 0% 7.0 ± 0% -30.00% (p=0.000 n=20+20) ``` Thanks to Tharsis who tasked me to help them increase TPS and who are keen on improving Tendermint and efficiency.
3 years ago
  1. # Unreleased Changes
  2. Friendly reminder: We have a [bug bounty program](https://hackerone.com/cosmos).
  3. ## vX.X
  4. Month, DD, YYYY
  5. Special thanks to external contributors on this release:
  6. ### BREAKING CHANGES
  7. - CLI/RPC/Config
  8. - [rpc] \#7121 Remove the deprecated gRPC interface to the RPC service. (@creachadair)
  9. - [blocksync] \#7159 Remove support for disabling blocksync in any circumstance. (@tychoish)
  10. - [mempool] \#7171 Remove legacy mempool implementation. (@tychoish)
  11. - [rpc] \#7575 Rework how RPC responses are written back via HTTP. (@creachadair)
  12. - [rpc] \#7713 Remove unused options for websocket clients. (@creachadair)
  13. - Apps
  14. - [proto/tendermint] \#6976 Remove core protobuf files in favor of only housing them in the [tendermint/spec](https://github.com/tendermint/spec) repository.
  15. - P2P Protocol
  16. - [p2p] \#7035 Remove legacy P2P routing implementation and associated configuration options. (@tychoish)
  17. - [p2p] \#7265 Peer manager reduces peer score for each failed dial attempts for peers that have not successfully dialed. (@tychoish)
  18. - [p2p] [\#7594](https://github.com/tendermint/tendermint/pull/7594) always advertise self, to enable mutual address discovery. (@altergui)
  19. - Go API
  20. - [rpc] \#7474 Remove the "URI" RPC client. (@creachadair)
  21. - [libs/pubsub] \#7451 Internalize the pubsub packages. (@creachadair)
  22. - [libs/sync] \#7450 Internalize and remove the library. (@creachadair)
  23. - [libs/async] \#7449 Move library to internal. (@creachadair)
  24. - [pubsub] \#7231 Remove unbuffered subscriptions and rework the Subscription interface. (@creachadair)
  25. - [eventbus] \#7231 Move the EventBus type to the internal/eventbus package. (@creachadair)
  26. - [blocksync] \#7046 Remove v2 implementation of the blocksync service and recactor, which was disabled in the previous release. (@tychoish)
  27. - [p2p] \#7064 Remove WDRR queue implementation. (@tychoish)
  28. - [config] \#7169 `WriteConfigFile` now returns an error. (@tychoish)
  29. - [libs/service] \#7288 Remove SetLogger method on `service.Service` interface. (@tychoish)
  30. - [abci/client] \#7607 Simplify client interface (removes most "async" methods). (@creachadair)
  31. - [libs/json] \#7673 Remove the libs/json (tmjson) library. (@creachadair)
  32. - Blockchain Protocol
  33. ### FEATURES
  34. - [rpc] [\#7270](https://github.com/tendermint/tendermint/pull/7270) Add `header` and `header_by_hash` RPC Client queries. (@fedekunze)
  35. - [rpc] [\#7701] Add `ApplicationInfo` to `status` rpc call which contains the application version. (@jonasbostoen)
  36. - [cli] [#7033](https://github.com/tendermint/tendermint/pull/7033) Add a `rollback` command to rollback to the previous tendermint state in the event of non-determinstic app hash or reverting an upgrade.
  37. - [mempool, rpc] \#7041 Add removeTx operation to the RPC layer. (@tychoish)
  38. - [consensus] \#7354 add a new `synchrony` field to the `ConsensusParameter` struct for controlling the parameters of the proposer-based timestamp algorithm. (@williambanfield)
  39. - [consensus] \#7376 Update the proposal logic per the Propose-based timestamps specification so that the proposer will wait for the previous block time to occur before proposing the next block. (@williambanfield)
  40. - [consensus] \#7391 Use the proposed block timestamp as the proposal timestamp. Update the block validation logic to ensure that the proposed block's timestamp matches the timestamp in the proposal message. (@williambanfield)
  41. - [consensus] \#7415 Update proposal validation logic to Prevote nil if a proposal does not meet the conditions for Timelyness per the proposer-based timestamp specification. (@anca)
  42. - [consensus] \#7382 Update block validation to no longer require the block timestamp to be the median of the timestamps of the previous commit. (@anca)
  43. - [consensus] \#7711 Use the proposer timestamp for the first height instead of the genesis time. Chains will still start consensus at the genesis time. (@anca)
  44. ### IMPROVEMENTS
  45. - [internal/protoio] \#7325 Optimized `MarshalDelimited` by inlining the common case and using a `sync.Pool` in the worst case. (@odeke-em)
  46. - [consensus] \#6969 remove logic to 'unlock' a locked block.
  47. - [evidence] \#7700 Evidence messages contain single Evidence instead of EvidenceList (@jmalicevic)
  48. - [pubsub] \#7319 Performance improvements for the event query API (@creachadair)
  49. - [node] \#7521 Define concrete type for seed node implementation (@spacech1mp)
  50. - [rpc] \#7612 paginate mempool /unconfirmed_txs rpc endpoint (@spacech1mp)
  51. - [light] [\#7536](https://github.com/tendermint/tendermint/pull/7536) rpc /status call returns info about the light client (@jmalicevic)
  52. - [types] \#7765 Replace EvidenceData with EvidenceList to avoid unnecessary nesting of evidence fields within a block. (@jmalicevic)
  53. ### BUG FIXES
  54. - fix: assignment copies lock value in `BitArray.UnmarshalJSON()` (@lklimek)
  55. - [light] \#7640 Light Client: fix absence proof verification (@ashcherbakov)
  56. - [light] \#7641 Light Client: fix querying against the latest height (@ashcherbakov)