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

Reduce excessive server logging. #1011

Merged
merged 2 commits into from
Oct 29, 2020
Merged

Conversation

PeterAdams-A
Copy link
Contributor

Motivation:

When running a unary server, sending the response can put the
HTTP1ToGRPCServerCodec into ignore state. This happens before
the end of stream is processed. The 2 end stream messages
(empty buffer of data and end) then trigger logging.

Modifications:

Ignore end and empty data without logging when codec is in
ignore state.

Result:

Less logging and hence faster performance.

Motivation:

When running a unary server, sending the response can put the
HTTP1ToGRPCServerCodec into ignore state.  This happens before
the end of stream is processed.  The 2 end stream messages
(empty buffer of data and end) then trigger logging.

Modifications:

Ignore end and empty data without logging when codec is in
ignore state.

Result:

Less logging and hence faster performance.
Comment on lines 133 to 139
if case let .body(body) = unwrappedData, body.readableBytes == 0 {
return // Ignoring a read of zero bytes is always fine.
} else if case .end = unwrappedData {
return // Ignoring an end stream is not an event worth reporting.
}
self.logger.notice("ignoring read data", metadata: ["data": "\(data)"])
return
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we switch on the unwrappedData here instead? We can drop our return count to 1 and neaten it up a bit.

Something like:

switch unwrappedData {
  case let .body(body) where body.readableBytes == 0:
    ()
  case .end:
    ()
  default:
    self.logger.notice(...)
  }
  return
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also we may as well log the unwrappedData instead of the data now.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also you'll need to run ./scripts/format.sh.

@glbrntt glbrntt added the 🔨 semver/patch No public API change. label Oct 23, 2020
@PeterAdams-A PeterAdams-A requested a review from glbrntt October 23, 2020 15:26
@glbrntt glbrntt merged commit 6f47178 into grpc:main Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants