From 7427a0ba7ae44a745335c43c3f4da58ce477ec44 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 2 May 2024 17:35:50 -0600 Subject: [PATCH] perf(event bus): Remove expensive Logger debug call in PublishEventTx (backport #2911) (#2937) (#38) Component of #2869 This on its own is an expected 1% speedup to blocksync on osmosis mainnet right now. I originally considered keeping the log lines but with only creating the logger cost if there is an error, but these are debug logs I've never seen. I think its better to just remove these debug logs directly, rather than worry about maintaining them. These aren't even that concerning scenarios I feel like, as more of the stack moves away from these. --- #### PR checklist - [x] Tests written/updated - Covered by existing tests - [x] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [X] Updated relevant documentation (`docs/` or `spec/`) and code comments - [X] Title follows the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec
This is an automatic backport of pull request #2911 done by [Mergify](https://mergify.com). --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Dev Ojha Co-authored-by: Andy Nogueira (cherry picked from commit a9991fd82c81115d51d7fb05bd49733ae0e64cff) --- .../improvements/2911-remove-event-bus-debug-logs.md | 2 ++ types/event_bus.go | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 .changelog/unreleased/improvements/2911-remove-event-bus-debug-logs.md diff --git a/.changelog/unreleased/improvements/2911-remove-event-bus-debug-logs.md b/.changelog/unreleased/improvements/2911-remove-event-bus-debug-logs.md new file mode 100644 index 0000000000..a008e2482a --- /dev/null +++ b/.changelog/unreleased/improvements/2911-remove-event-bus-debug-logs.md @@ -0,0 +1,2 @@ +- `[event-bus]` Remove the debug logs in PublishEventTx, which were noticed production slowdowns. + ([\#2911](https://github.com/cometbft/cometbft/pull/2911)) \ No newline at end of file diff --git a/types/event_bus.go b/types/event_bus.go index cd42ec05dc..b22df3b9da 100644 --- a/types/event_bus.go +++ b/types/event_bus.go @@ -109,17 +109,15 @@ func (b *EventBus) Publish(eventType string, eventData TMEventData) error { // map of stringified events where each key is composed of the event // type and each of the event's attributes keys in the form of // "{event.Type}.{attribute.Key}" and the value is each attribute's value. -func (b *EventBus) validateAndStringifyEvents(events []types.Event, logger log.Logger) map[string][]string { +func (*EventBus) validateAndStringifyEvents(events []types.Event) map[string][]string { result := make(map[string][]string) for _, event := range events { if len(event.Type) == 0 { - logger.Debug("Got an event with an empty type (skipping)", "event", event) continue } for _, attr := range event.Attributes { if len(attr.Key) == 0 { - logger.Debug("Got an event attribute with an empty key(skipping)", "event", event) continue } @@ -136,7 +134,7 @@ func (b *EventBus) PublishEventNewBlock(data EventDataNewBlock) error { ctx := context.Background() resultEvents := append(data.ResultBeginBlock.Events, data.ResultEndBlock.Events...) - events := b.validateAndStringifyEvents(resultEvents, b.Logger.With("block", data.Block.StringShort())) + events := b.validateAndStringifyEvents(resultEvents) // add predefined new block event events[EventTypeKey] = append(events[EventTypeKey], EventNewBlock) @@ -150,7 +148,7 @@ func (b *EventBus) PublishEventNewBlockHeader(data EventDataNewBlockHeader) erro resultTags := append(data.ResultBeginBlock.Events, data.ResultEndBlock.Events...) // TODO: Create StringShort method for Header and use it in logger. - events := b.validateAndStringifyEvents(resultTags, b.Logger.With("header", data.Header)) + events := b.validateAndStringifyEvents(resultTags) // add predefined new block header event events[EventTypeKey] = append(events[EventTypeKey], EventNewBlockHeader) @@ -177,7 +175,7 @@ func (b *EventBus) PublishEventTx(data EventDataTx) error { // no explicit deadline for publishing events ctx := context.Background() - events := b.validateAndStringifyEvents(data.Result.Events, b.Logger.With("tx", data.Tx)) + events := b.validateAndStringifyEvents(data.Result.Events) // add predefined compositeKeys events[EventTypeKey] = append(events[EventTypeKey], EventTx)