Skip to content

Added cache for base Spec object properties #168

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Aribros
Copy link
Contributor

@Aribros Aribros commented Sep 27, 2022

Made little performance improvement by temporary caching some already resolved references.

@NickSdot
Copy link

@Aribros, thank you for that! I've been using your PR when working with a large spec. It makes things a whole order of magnitude faster. Resolving all the refs on my spec was impossible before applying this.

However, there is a pretty big downside, which only becomes apparent when working with larger specs.

The memory usage in my case ended up being ~330M. Also, the resulting size of the object - which I serialise and cache in the file system - is ~210M. I've tried to unset each context after resolving, but the size of the spec doesn't allow it in an acceptable time - or it just fails. It's just too many nested schemas in my case.

So I ended up combining your solution with a static cache property.

Result:
Memory usage is down to ~70M. The resulting serialised object size is down to only ~20M. Also, it runs in under one second.

Probably something to consider before this potentially gets merged. Anyway, your PR pointed me in the right direction. Thanks again.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants