-
Notifications
You must be signed in to change notification settings - Fork 71
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
Use felixge/httpsnoop approach to preserve additional interfaces #26
Conversation
any idea where the extra allocations are coming from? I don't think there are specific perm expectations, as I haven't seen any benchmarks before or specific user requests. The StatusCodeTracer clearly seemed like an overkill, and your benchmark proves it. |
Looking at the escape analysis logs, It looks like the two new function literals account for two of the allocations. The pointer to status escapes as well, but so does the For comparison, Opencensus has a probably more performant solution that is also less correct because it will pass type assertions that it really shouldn't in some scenarios. |
it appears OpenCensus code has been upgraded to use an approach similar to httpsnoop |
I closed out my PR #25 since it sounds like this is the favored approach. @yurishkuro what would you like to see here? Anything I could help with to move this forward? |
We can probably merge this. There's a way to improve performance, but not sure how critical it is for this lib. |
Great! Looking forward to having it brought in 🎉 |
any steps to get this merged? |
What remains to have this merged, besides a rebase? I'd be happy to help if there's anything remaining :) |
My suggesting is to not use httpsnoop (unnecessary external dependency), and instead implement the same way as done in OpenCensus |
It's more efficient than using httpsnoop.
I updated this to use that implementation. New benchmark results follow.
|
great! @yurishkuro please, merge it =) |
Gonna be using this branch until it's merged. Need this for grpc streaming responses. |
cn, i1 = w.ResponseWriter.(http.CloseNotifier) | ||
fl, i3 = w.ResponseWriter.(http.Flusher) | ||
rf, i4 = w.ResponseWriter.(io.ReaderFrom) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
httpsnoop covers 5 interfaces, but this code only covers 4, any reason? Is it because of older versions of Go? I think we need to drop support for anything but N and N-1 versions, per Go language own policy.
// - http.Flusher
// - http.CloseNotifier
// - http.Hijacker
// - io.ReaderFrom
// - http.Pusher
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this is for "old" - I think we should drop this file altogether
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new PR - #36
Just like #25 and #11, but I've used
httpsnoop.Wrap
instead ofhttpsnoop.CaptureMetrics
. There is a performance overhead here, so I added a benchmark to measure it. On my machine, I get the following resultsBefore
After (
httpsnoop.Wrap
)This one is what I've actually implemented
After (
httpsnoop.CaptureMetrics
as in #11)This is what is in #11 for comparison.
I'm not sure what the performance expectations of this package are, so if this is not sufficient, I think this could be refined further by copying the codegen approach in httpsnoop that underlies
httpsnoop.Wrap
. Let me know and I'd be happy to give that a shot.