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

ensure recursion guard is always used as a stack #1166

Merged
merged 1 commit into from
Jan 19, 2024

Conversation

davidhewitt
Copy link
Contributor

Change Summary

Introduces RecursionGuard as a type which goes in a function frame and releases on drop.

This fixes the issue seen updating to 2.16.0.

Because RecursionGuard takes ownership of the state, it guarantees that two guards can't overlap their usage of the state.

Related issue number

Checklist

  • Unit tests for the changes exist
  • Documentation reflects the changes where applicable
  • Pydantic tests pass with this pydantic-core (except for expected changes)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Sorry, something went wrong.

Copy link

codspeed-hq bot commented Jan 18, 2024

CodSpeed Performance Report

Merging #1166 will improve performances by 25.14%

Comparing dh/ser-rec-guard (670fd51) with main (4da7192)

Summary

⚡ 2 improvements
✅ 144 untouched benchmarks

Benchmarks breakdown

Benchmark main dh/ser-rec-guard Change
test_core_future_str 39.4 µs 31.5 µs +25.14%
test_to_json_list_of_lists 10.2 ms 8.4 ms +21.5%

Copy link

codecov bot commented Jan 19, 2024

Codecov Report

Merging #1166 (670fd51) into main (4da7192) will increase coverage by 0.02%.
The diff coverage is 98.76%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1166      +/-   ##
==========================================
+ Coverage   89.97%   90.00%   +0.02%     
==========================================
  Files         106      106              
  Lines       16618    16656      +38     
  Branches       36       36              
==========================================
+ Hits        14952    14991      +39     
+ Misses       1659     1658       -1     
  Partials        7        7              
Files Coverage Δ
src/recursion_guard.rs 100.00% <100.00%> (ø)
src/serializers/extra.rs 99.08% <100.00%> (+0.01%) ⬆️
src/serializers/infer.rs 95.23% <100.00%> (+0.32%) ⬆️
src/serializers/mod.rs 99.53% <100.00%> (ø)
src/serializers/type_serializers/definitions.rs 98.46% <100.00%> (-0.11%) ⬇️
src/validators/generator.rs 92.85% <ø> (ø)
src/validators/mod.rs 95.37% <100.00%> (ø)
src/validators/validation_state.rs 100.00% <100.00%> (ø)
src/validators/definitions.rs 95.38% <83.33%> (+0.57%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4da7192...670fd51. Read the comment docs.

Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

LGTM.

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.

None yet

3 participants