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

Improve the V8 -> V7 bridge implementation and add benchmarks #1257

Merged
merged 1 commit into from
Jun 6, 2023

Conversation

martintmk
Copy link
Contributor

@martintmk martintmk commented Jun 6, 2023

The issue or feature being addressed

Follow up of #1255

Details on the issue fix or feature implementation

While playing with bridge I noticed some issues:

  • Setting context properties in V7 is not reflected in V8 until the execution ends. To fix this, both ResilienceProperties need to use the same dictionary as Context. I have introduced pub-internal LegacySupport that allows this scenario.
  • The bridge was setting the Polly.Legacy.Context value unnecessary, we can use the state for that and avoid dictionary lookup.

Additionally, I have added the benchmark for the bride. It reveals the non-trivial overhead.

Confirm the following

  • I started this PR by branching from the head of the default branch
  • I have targeted the PR to merge into the default branch
  • I have included unit tests for the issue/feature
  • I have successfully run a local build

@martintmk martintmk added the v8 Issues related to the new version 8 of the Polly library. label Jun 6, 2023
@martintmk martintmk added this to the v8.0.0 milestone Jun 6, 2023
| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio |
|----------------------- |----------:|---------:|---------:|------:|--------:|-------:|----------:|------------:|
| NoOpAsync | 85.38 ns | 1.001 ns | 1.371 ns | 1.00 | 0.00 | 0.0120 | 304 B | 1.00 |
| NullResilienceStrategy | 416.38 ns | 1.924 ns | 2.820 ns | 4.87 | 0.10 | 0.0148 | 376 B | 1.24 |
Copy link
Member

Choose a reason for hiding this comment

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

Wow - that's a lot!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, there is a resilience context lookup, lambda conversion, and bunch of other stuff. It really adds up.

@codecov
Copy link

codecov bot commented Jun 6, 2023

Codecov Report

Merging #1257 (4eb3cdf) into main (b0a6a38) will increase coverage by 0.04%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1257      +/-   ##
==========================================
+ Coverage   83.08%   83.12%   +0.04%     
==========================================
  Files         268      269       +1     
  Lines        6218     6239      +21     
  Branches      979      976       -3     
==========================================
+ Hits         5166     5186      +20     
- Misses        843      844       +1     
  Partials      209      209              
Flag Coverage Δ
linux 83.12% <100.00%> (+0.04%) ⬆️
macos 83.12% <100.00%> (+0.04%) ⬆️
windows ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/Polly.Core/ResilienceProperties.cs 100.00% <100.00%> (ø)
src/Polly.Core/Utils/LegacySupport.cs 100.00% <100.00%> (ø)
...lly/Utilities/Wrappers/ResilienceContextFactory.cs 100.00% <100.00%> (ø)
.../Wrappers/ResilienceStrategyAsyncPolicy.TResult.cs 100.00% <100.00%> (ø)
...tilities/Wrappers/ResilienceStrategyAsyncPolicy.cs 100.00% <100.00%> (ø)
...s/Wrappers/ResilienceStrategySyncPolicy.TResult.cs 100.00% <100.00%> (ø)
...Utilities/Wrappers/ResilienceStrategySyncPolicy.cs 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

@martintmk martintmk changed the title Improve the V7 -> V8 bridge implementation and add benchmarks Improve the V8 -> V7 bridge implementation and add benchmarks Jun 6, 2023
@martintmk martintmk enabled auto-merge (squash) June 6, 2023 11:11
@martintmk martintmk merged commit 4141081 into main Jun 6, 2023
@martintmk martintmk deleted the mtomka/v8-to-v7-wrappers branch June 6, 2023 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v8 Issues related to the new version 8 of the Polly library.
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants