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.

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