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

fix(prerender): free up memory after each route is written to the disk #1536

Merged
merged 1 commit into from
Aug 4, 2023

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Aug 4, 2023

πŸ”— Linked issue

Resolves #1535

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR resolves the high memory usage issue when prerendering lots of routes by cleaning up the memory of route contents as soon as being written to the disk.

Since we were already typing the route.data and route.contents as optional, as a non breaking change they are only available (and can be set) before disk write. We could additionally support reading back contents from disk when accessing .data and .contents getters using fs sync methods but I think we can do it only if necessary.

Testing on reproduction in #1535 there seems no memory leaks anymore generating all 100k routes.

image

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codecov
Copy link

codecov bot commented Aug 4, 2023

Codecov Report

Merging #1536 (be5b7b8) into main (451d314) will decrease coverage by 0.10%.
The diff coverage is 57.69%.

@@            Coverage Diff             @@
##             main    #1536      +/-   ##
==========================================
- Coverage   76.25%   76.15%   -0.10%     
==========================================
  Files          73       73              
  Lines        7478     7494      +16     
  Branches      734      733       -1     
==========================================
+ Hits         5702     5707       +5     
- Misses       1775     1786      +11     
  Partials        1        1              
Files Changed Coverage Ξ”
src/prerender.ts 84.81% <57.69%> (-2.27%) ⬇️

@pi0 pi0 merged commit 2adeebb into main Aug 4, 2023
6 of 7 checks passed
@pi0 pi0 deleted the fix/prerender-mem branch August 4, 2023 18:46
@pi0 pi0 mentioned this pull request Aug 21, 2023
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.

prerendered routes kept in memory
1 participant