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

perf: Cache reference lookups for subschemas #894

Merged
merged 4 commits into from
Dec 17, 2021
Merged

perf: Cache reference lookups for subschemas #894

merged 4 commits into from
Dec 17, 2021

Conversation

Stranger6667
Copy link
Contributor

@Stranger6667 Stranger6667 commented Dec 15, 2021

The latest commit cuts the time to 8.08942461013794 sec which is quite close to 3.2.0 version performance (5.38702654838562 sec on my machine)

@codecov
Copy link

codecov bot commented Dec 15, 2021

Codecov Report

Merging #894 (251763a) into main (0878727) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #894   +/-   ##
=======================================
  Coverage   98.25%   98.26%           
=======================================
  Files          20       20           
  Lines        3152     3170   +18     
  Branches      423      426    +3     
=======================================
+ Hits         3097     3115   +18     
  Misses         44       44           
  Partials       11       11           
Impacted Files Coverage Δ
jsonschema/validators.py 97.42% <100.00%> (+0.18%) ⬆️

Continue to review full report at Codecov.

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

@Stranger6667
Copy link
Contributor Author

Another small thing that cuts the time to 7.816486835479736 sec & removes ~2M func calls from that example code is replacing Validator.evolve method with evolve = attr.evolve so there is no extra function call overhead. Let me know if this change would be ok :)

@Julian
Copy link
Member

Julian commented Dec 16, 2021

Ayy CPython... Yes that's likely fine with me too as long as we preserve the documentation!

CHANGELOG.rst Outdated
@@ -5,6 +5,7 @@ v4.3.0
certain input types (#893)
* Cache reference lookups for subschemas (#893)
* Use cached lookups for resolving fragments if the referent document is known (#893)
* Replace the ``Validator.evolve`` method with an equivalent class attribute
Copy link
Member

Choose a reason for hiding this comment

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

This is an implementation detail, we can save mentioning it I think.

And for the other two I'd maybe just say something simpler like "resolving refs has had performance improvements" and have that cover the whole change, someone can look at the PR for details.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! :)

@Julian Julian merged commit d5c4d07 into python-jsonschema:main Dec 17, 2021
@Julian
Copy link
Member

Julian commented Dec 17, 2021

Fantastic, thanks again, really appreciate the time! Merging.

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

2 participants