Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cache node hashing #150

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

Merged
Cito merged 2 commits into graphql-python:main from closeio:cache-node-hash
Dec 11, 2021
Merged

Cache node hashing #150

Cito merged 2 commits into graphql-python:main from closeio:cache-node-hash
Dec 11, 2021

Conversation

Copy link
Contributor

@AlecRosenbaum AlecRosenbaum commented Dec 10, 2021

This change adds basic caching for Node.__hash__. The primary goal of this change is to optimize validation. The benchmark I tested against is tests/benchmarks/test_validation_gql.py.

Locally, this benchmark goes from 7ms to 4ms with this change. I've also done some testing against an internal schema from our application, using a large query from our application instead of the introspection query. In that test, validation time dropped from 28ms to 11ms locally.

Ambro17, Cito, leszekhanusz, wojcikstefan, and squeaky-pl reacted with thumbs up emoji
Copy link
Member

Cito commented Dec 10, 2021

Thanks, will check this out. One minor disadvantage ist that when you modify the AST, then you must also reset the cashed hash value. Or maybe we should do it automatically in the __setattr__ method?

AlecRosenbaum reacted with thumbs up emoji

@Cito Cito self-assigned this Dec 10, 2021
@Cito Cito added this to the v3.2 milestone Dec 10, 2021
@Cito Cito added the optimization Code optimizations and performance issues label Dec 10, 2021
Copy link
Contributor Author

Good idea. I get about the same results with an added __setattr__ override that resets _hash.

Cito reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@Cito Cito Awaiting requested review from Cito Cito is a code owner

Assignees

@Cito Cito

Labels
optimization Code optimizations and performance issues
Projects
None yet
Milestone
v3.2
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /