Skip to content

Performance regression & OOM errors when building medium sized blogs with finite resources #14893

@Xyz3R

Description

@Xyz3R

Astro Info

Astro                    v5.16.0
Node                     v22.20.0
System                   Linux (x64)
Package Manager          bun (build was run using node, not bun)
Output                   static
Adapter                  none
Integrations             @astrojs/sitemap

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Testing environment

  • Fresh project using blog template
  • Added some sample text content (+script to generate them)

Problem Description
When building a medium sized project, a lot more memory than expected is consumed which causes severe performance regressions during built if not available. This can even end in OOM errors if the content is even larger.

How To Reproduce
This repo contains the default blog template + 10_000 .md files with lorem ipsum content.

To reproduce the issue, run the following commands:

  1. With 6GB RAM constraint: This will take a substantial amount of time to finish (10+ minutes)
t node --max-old-space-size=6000 ./node_modules/.bin/astro build
  1. As comparison, run the same command but allow it to consume 16GB RAM. This will finish in a few seconds.
t node --max-old-space-size=16000 ./node_modules/.bin/astro build
  1. Killing the entire build with even more content
    3.1 Open src/content/blog/third-post.md (this is used as the reference file) and duplicate its content by simply copy pasting the entire content below the frontmatter multiple times (1 or 2 additional times should do the trick)
    3.2 run sh ./create-posts.sh - this will clone the file "third-post.md" 10000 times. You can also specify a number as an argument to change this amount
    3.3 run the build and watch how it gets stuck on syncing content - no matter how much memory is available. I've let it run for quite some time but it never finished while continously using more until it crashes with an OOM depending on the amount of memory available to the build VM.

What's the expected result?

The build should work. I would not expect 10.000 simple text markdown files with a total size of <30mb to consume over 6GB or RAM during build so it should not struggle this much.

Link to Minimal Reproducible Example

https://github.com/Xyz3R/astro-performance-regression-low-memory

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P4: importantViolate documented behavior or significantly impacts performance (priority)help wantedPlease help with this issue!regression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions