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

use vectorcall calling convention for performance #792

Closed
wants to merge 1 commit into from

Conversation

davidhewitt
Copy link
Contributor

@davidhewitt davidhewitt commented Jul 20, 2023

Change Summary

Uses Python's "vectorcall" calling convention instead of PyAny::call1 to avoid creating intermediate tuples. Only works on supported Python versions. (3.9+, I think, let's confirm with CI.)

In the long term I'd like to add a feature to upstream PyO3 which does this and also supports keyword arguments. Seems like we don't generally use keyword arguments so not relevant to us here. Probably also with a more generic interface than just a slice-of-any as input.

Related issue number

N/A

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

@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Merging #792 (ba4fbe7) into main (9b540d0) will decrease coverage by 0.13%.
The diff coverage is 78.64%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #792      +/-   ##
==========================================
- Coverage   93.53%   93.40%   -0.13%     
==========================================
  Files         100      101       +1     
  Lines       14376    14441      +65     
  Branches       25       25              
==========================================
+ Hits        13446    13489      +43     
- Misses        924      946      +22     
  Partials        6        6              
Impacted Files Coverage Δ
src/lib.rs 100.00% <ø> (ø)
src/py_vectorcall.rs 52.17% <52.17%> (ø)
src/input/input_python.rs 98.11% <100.00%> (+0.01%) ⬆️
src/serializers/filter.rs 96.10% <100.00%> (+0.03%) ⬆️
src/serializers/infer.rs 96.94% <100.00%> (ø)
src/serializers/type_serializers/format.rs 91.11% <100.00%> (ø)
src/serializers/type_serializers/function.rs 96.22% <100.00%> (+0.08%) ⬆️
src/url.rs 98.30% <100.00%> (ø)
src/validators/function.rs 90.83% <100.00%> (+0.17%) ⬆️
src/validators/union.rs 81.57% <100.00%> (ø)
... and 1 more

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 f38bea6...ba4fbe7. Read the comment docs.

@codspeed-hq
Copy link

codspeed-hq bot commented Jul 20, 2023

CodSpeed Performance Report

Merging #792 will degrade performances by 10.5%

Comparing dh/vectorcall (ba4fbe7) with main (f38bea6)

Summary

❌ 1 regressions
✅ 125 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main dh/vectorcall Change
test_dont_raise_error_no_info 22.6 µs 25.3 µs -10.5%

@davidhewitt
Copy link
Contributor Author

This doesn't seem to meaningfully improve performance, but I'll leave it here for the moment as I found it was helpful in decimal validation in #763.

@davidhewitt
Copy link
Contributor Author

Correction: it makes barely any difference even in #763 so I'll close this for now.

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.

1 participant