Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(event bus): Remove expensive Logger debug call in PublishEventTx… (backport #38) #44

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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))
10 changes: 4 additions & 6 deletions types/event_bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Loading