Skip to content

contrib/internal/httptrace: improve performance of span starts#2128

Merged
knusbaum merged 4 commits into
release-v1.53.xfrom
knusbaum/http-perf
Jul 19, 2023
Merged

contrib/internal/httptrace: improve performance of span starts#2128
knusbaum merged 4 commits into
release-v1.53.xfrom
knusbaum/http-perf

Conversation

@knusbaum

Copy link
Copy Markdown
Contributor

What does this PR do?

This commit improves the performance of starting a span by reducing work
done, especially allocations.

Motivation

We were seeing a large increase in memory and CPU usage while starting spans compared to previous versions.

Describe how to test/QA your changes

Reviewer's Checklist

  • Changed code has unit tests for its functionality.
  • If this interacts with the agent in a new way, a system test has been added.

This commit improves the performance of starting a span by reducing work
done, especially allocations.
@knusbaum
knusbaum requested a review from a team July 19, 2023 16:08
@knusbaum
knusbaum requested a review from a team as a code owner July 19, 2023 16:08
@knusbaum

Copy link
Copy Markdown
Contributor Author
$ benchstat old.bench new.bench 
name                 old time/op    new time/op    delta
StartRequestSpan-16     788ns ±13%     160ns ± 6%  -79.64%  (p=0.000 n=10+10)

name                 old alloc/op   new alloc/op   delta
StartRequestSpan-16      768B ± 0%      224B ± 0%  -70.83%  (p=0.000 n=10+10)

name                 old allocs/op  new allocs/op  delta
StartRequestSpan-16      21.0 ± 0%       5.0 ± 0%  -76.19%  (p=0.000 n=10+10)

@knusbaum
knusbaum changed the base branch from main to release-v1.53.x July 19, 2023 16:09
Comment thread internal/namingschema/op_client_server.go Outdated
@knusbaum knusbaum changed the title Knusbaum/http perf contrib/internal/httptrace: improve performance of span starts Jul 19, 2023
Comment thread contrib/internal/httptrace/httptrace.go Outdated
Comment thread contrib/internal/httptrace/httptrace_test.go
@pr-commenter

pr-commenter Bot commented Jul 19, 2023

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2023-07-19 19:53:56

Comparing candidate commit c65db5c in PR branch knusbaum/http-perf with baseline commit f905f70 in branch release-v1.53.x.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 27 metrics, 0 unstable metrics.

@knusbaum

Copy link
Copy Markdown
Contributor Author

New benchstat output:

$ benchstat old.bench new.bench 
name                 old time/op    new time/op    delta
StartRequestSpan-16    1.08µs ±13%    0.35µs ± 3%  -67.92%  (p=0.000 n=10+10)

name                 old alloc/op   new alloc/op   delta
StartRequestSpan-16      768B ± 0%      264B ± 0%  -65.62%  (p=0.000 n=10+10)

name                 old allocs/op  new allocs/op  delta
StartRequestSpan-16      21.0 ± 0%      10.0 ± 0%  -52.38%  (p=0.000 n=10+10)

@knusbaum
knusbaum merged commit 216e947 into release-v1.53.x Jul 19, 2023
@knusbaum
knusbaum deleted the knusbaum/http-perf branch July 19, 2023 20:05
knusbaum added a commit that referenced this pull request Jul 20, 2023
This commit improves the performance of starting a span by reducing work
done, especially allocations.
knusbaum added a commit that referenced this pull request Jul 20, 2023
…y-pick #2128) (#2135)

This commit improves the performance of starting a span by reducing work done, especially allocations.

Cherry-pick of #2128
katiehockman pushed a commit that referenced this pull request Jul 26, 2023
…y-pick #2128) (#2135)

This commit improves the performance of starting a span by reducing work done, especially allocations.

Cherry-pick of #2128
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants