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.

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