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

7x performance improvement #962

Merged
merged 1 commit into from
Oct 9, 2023
Merged

7x performance improvement #962

merged 1 commit into from
Oct 9, 2023

Conversation

EwenQuim
Copy link
Collaborator

@EwenQuim EwenQuim commented Oct 9, 2023

Hi ! Two weeks ago I made a PR improving the pascal function, because it was a bottleneck. I continued investigating and I found that it was often called with the same values. So this PR adds a very simple cache to this function, with a tremendous impact on performance.

Obvious duplicated calls to the pascal function

image image image image

Hidden duplicated calls

Some calls are made from different places of the codebase with the same input.

Solution proposed

A simple object acting as a cache.

Screenshots of the result

Before
image

After
image

99.9%+ hit ratio, this is huge !

Also, we can see that the memory does not grow too much, even with 15 million calls to the pascal function, it have only 10k keys, so it does not damage the user's memory. ✅ No need for a real cache library.

Going further

The default petstore.yml really is not a good OpenAPI doc to test on, because we can see that it does not have the size of a real project. Maybe a good idea for the future might be to test on a bigger document ?

@vercel
Copy link

vercel bot commented Oct 9, 2023

Someone is attempting to deploy a commit to a Personal Account owned by @anymaniax on Vercel.

@anymaniax first needs to authorize it.

Copy link
Owner

@anymaniax anymaniax left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

@anymaniax anymaniax merged commit 1899009 into anymaniax:master Oct 9, 2023
2 of 3 checks passed
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