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: remove avatar sizes from cache (3/4) #94

Merged
merged 11 commits into from
Nov 6, 2024

Conversation

privatenumber
Copy link
Member

@privatenumber privatenumber commented Nov 6, 2024

Important

This is a PR against #93
Diff: privatenumber/sponsorkit@webp-sharp...optimize-cache-more
#93 should be merged first

Description

  • We never need all 3 resolutions for an image so it was wasteful to be processing all 3 image sizes for every avatar

  • It was also wasteful to store them in the cache

  • Now, it only stores the highest resolution we need in the cache, and we process the image size we need as we use them. There's a cache to prevent re-computation.

  • I was able to slim down the code as well because we now no longer need to manage all 3 sizes

  • I also created a cache parser/stringifier to abstract out the buffer <-> base64 conversion

Results

  • Old cache size: 2.6 MB
  • New cache size: 931 KB

Linked Issues

Additional context

@privatenumber privatenumber marked this pull request as ready for review November 6, 2024 02:09
@privatenumber privatenumber changed the title perf: remove avatar sizes from cache (3/3) perf: remove avatar sizes from cache (3/4) Nov 6, 2024
@antfu antfu merged commit 00e51a6 into antfu-collective:main Nov 6, 2024
1 check 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.

2 participants