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.

79 lines
5.2 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. - [config] \#7930 Add new event subscription options and defaults. (@creachadair)
  14. - Apps
  15. - [tendermint/spec] \#7804 Migrate spec from [spec repo](https://github.com/tendermint/spec).
  16. - P2P Protocol
  17. - [p2p] \#7035 Remove legacy P2P routing implementation and associated configuration options. (@tychoish)
  18. - [p2p] \#7265 Peer manager reduces peer score for each failed dial attempts for peers that have not successfully dialed. (@tychoish)
  19. - [p2p] [\#7594](https://github.com/tendermint/tendermint/pull/7594) always advertise self, to enable mutual address discovery. (@altergui)
  20. - Go API
  21. - [rpc] \#7474 Remove the "URI" RPC client. (@creachadair)
  22. - [libs/pubsub] \#7451 Internalize the pubsub packages. (@creachadair)
  23. - [libs/sync] \#7450 Internalize and remove the library. (@creachadair)
  24. - [libs/async] \#7449 Move library to internal. (@creachadair)
  25. - [pubsub] \#7231 Remove unbuffered subscriptions and rework the Subscription interface. (@creachadair)
  26. - [eventbus] \#7231 Move the EventBus type to the internal/eventbus package. (@creachadair)
  27. - [blocksync] \#7046 Remove v2 implementation of the blocksync service and recactor, which was disabled in the previous release. (@tychoish)
  28. - [p2p] \#7064 Remove WDRR queue implementation. (@tychoish)
  29. - [config] \#7169 `WriteConfigFile` now returns an error. (@tychoish)
  30. - [libs/service] \#7288 Remove SetLogger method on `service.Service` interface. (@tychoish)
  31. - [abci/client] \#7607 Simplify client interface (removes most "async" methods). (@creachadair)
  32. - [libs/json] \#7673 Remove the libs/json (tmjson) library. (@creachadair)
  33. - Blockchain Protocol
  34. ### FEATURES
  35. - [rpc] [\#7270](https://github.com/tendermint/tendermint/pull/7270) Add `header` and `header_by_hash` RPC Client queries. (@fedekunze)
  36. - [rpc] [\#7701] Add `ApplicationInfo` to `status` rpc call which contains the application version. (@jonasbostoen)
  37. - [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.
  38. - [mempool, rpc] \#7041 Add removeTx operation to the RPC layer. (@tychoish)
  39. - [consensus] \#7354 add a new `synchrony` field to the `ConsensusParameter` struct for controlling the parameters of the proposer-based timestamp algorithm. (@williambanfield)
  40. - [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)
  41. - [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)
  42. - [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)
  43. - [consensus] \#7382 Update block validation to no longer require the block timestamp to be the median of the timestamps of the previous commit. (@anca)
  44. - [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)
  45. ### IMPROVEMENTS
  46. - [internal/protoio] \#7325 Optimized `MarshalDelimited` by inlining the common case and using a `sync.Pool` in the worst case. (@odeke-em)
  47. - [consensus] \#6969 remove logic to 'unlock' a locked block.
  48. - [evidence] \#7700 Evidence messages contain single Evidence instead of EvidenceList (@jmalicevic)
  49. - [evidence] \#7802 Evidence pool emits events when evidence is validated and updates a metric when the number of evidence in the evidence pool changes. (@jmalicevic)
  50. - [pubsub] \#7319 Performance improvements for the event query API (@creachadair)
  51. - [node] \#7521 Define concrete type for seed node implementation (@spacech1mp)
  52. - [rpc] \#7612 paginate mempool /unconfirmed_txs rpc endpoint (@spacech1mp)
  53. - [light] [\#7536](https://github.com/tendermint/tendermint/pull/7536) rpc /status call returns info about the light client (@jmalicevic)
  54. - [types] \#7765 Replace EvidenceData with EvidenceList to avoid unnecessary nesting of evidence fields within a block. (@jmalicevic)
  55. ### BUG FIXES
  56. - fix: assignment copies lock value in `BitArray.UnmarshalJSON()` (@lklimek)
  57. - [light] \#7640 Light Client: fix absence proof verification (@ashcherbakov)
  58. - [light] \#7641 Light Client: fix querying against the latest height (@ashcherbakov)
  59. - [cli] [#7837](https://github.com/tendermint/tendermint/pull/7837) fix app hash in state rollback. (@yihuang)