Skip to content

Conversation

@CodeBlanch
Copy link
Contributor

Adding the benchmarks used on dotnet/runtime#40544

/cc @noahfalk @tarekgh

{
int total = 0;

for (int i = 0; i < NumberOfActivities; i++)
Copy link
Member

Choose a reason for hiding this comment

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

for [](start = 12, length = 3)

do we really need to loop? Benchmark already repeat the method execution anyway and we can get he exact number for the enumeration.

I would suggest too to create multiple static activities with different tags count. we can have the perf numbers for short, medium and long tags count.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the looping. Added small/large tests.

}

[Benchmark]
public void OTelHelperActivityTagObjects()
Copy link
Member

Choose a reason for hiding this comment

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

OTelHelperActivityTagObjects [](start = 20, length = 28)

could you please use the full word OpenTelemetry instead?

Copy link
Member

@tarekgh tarekgh Aug 19, 2020

Choose a reason for hiding this comment

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

Also, are we using OpenTelemetry because this how it call the Activity for enumeration? Does OTel create Enumerator as this test does? I am asking to know if it is worth it to complicate the test here. I am not pushing back though.


In reply to: 473440210 [](ancestors = 473440210)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed all the OpenTelemetry stuff.

}

// A helper class for enumerating over IEnumerable<TItem> without allocation if a struct enumerator is available.
private class Enumerator<TEnumerable, TItem, TState>
Copy link
Member

Choose a reason for hiding this comment

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

Enumerator [](start = 22, length = 10)

I am not really sure if it is good to test the internals with the reflection and code emit. what is really the goal here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These benchmarks were written for the other PR, really. I needed to make sure the struct enumerators worked for completely removing the allocation with the reflection mechanism, and also show there was an allocation reduction for the standard enumeration too. I opened this PR because I think @noahfalk said it would be useful. So my goal now is just to provide usefulness to future users of Activity 😄 I can remove the OpenTelemetry stuff, or I can close the PR completely if we don't think it will be that useful. LMK

Copy link
Member

Choose a reason for hiding this comment

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

Adding perf tests for Activity is useful. I suggest removing all OTel stuff and keep the simple test cases for the enumerating tags, links...etc. Thanks a lot for all your provided help.

@tarekgh
Copy link
Member

tarekgh commented Aug 19, 2020

CC @adamsitnik if he has any comment.

@tarekgh
Copy link
Member

tarekgh commented Aug 20, 2020

@CodeBlanch thanks for updating it. LGTM. I assume you ran it and the output is reasonable to you. right.

@adamsitnik @DrewScoggins looks I don't have a permission to merge in this repo. could you please have a look and merge it if you don't have any comment? Thanks.

@CodeBlanch
Copy link
Contributor Author

@tarekgh Ya it's running fine. Here's the output:

Method Mean Error StdDev Median Min Max Gen 0 Gen 1 Gen 2 Allocated
EnumerateActivityTagsSmall 64.20 ns 2.596 ns 2.990 ns 64.97 ns 59.36 ns 70.10 ns 0.0065 - - 56 B
EnumerateActivityTagsLarge 10,649.76 ns 1,301.307 ns 1,498.587 ns 9,959.51 ns 9,232.34 ns 13,946.43 ns - - - 56 B
EnumerateActivityTagObjectsSmall 89.92 ns 3.850 ns 4.434 ns 88.89 ns 83.85 ns 98.86 ns 0.0044 - - 40 B
EnumerateActivityTagObjectsLarge 16,737.40 ns 808.777 ns 794.327 ns 16,513.94 ns 15,501.91 ns 18,173.94 ns - - - 40 B
EnumerateActivityLinksSmall 116.74 ns 0.812 ns 0.634 ns 116.70 ns 115.73 ns 117.67 ns 0.0072 - - 64 B
EnumerateActivityLinksLarge 22,298.54 ns 409.880 ns 383.402 ns 22,225.34 ns 21,698.86 ns 22,929.51 ns - - - 64 B
EnumerateActivityEventsSmall 88.37 ns 1.154 ns 1.080 ns 88.34 ns 86.60 ns 90.12 ns 0.0065 - - 56 B
EnumerateActivityEventsLarge 18,992.88 ns 290.204 ns 271.457 ns 19,048.33 ns 18,594.74 ns 19,382.68 ns - - - 56 B
EnumerateActivityLinkTagsSmall 89.10 ns 9.694 ns 10.775 ns 85.42 ns 74.65 ns 114.33 ns 0.0057 - - 48 B
EnumerateActivityLinkTagsLarge 14,855.37 ns 1,645.641 ns 1,760.818 ns 14,261.70 ns 13,465.29 ns 19,684.47 ns - - - 48 B

@DrewScoggins
Copy link
Member

LGTM

@DrewScoggins DrewScoggins merged commit 524a605 into dotnet:master Aug 21, 2020
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.

3 participants