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

[Performance] Writing templates is slow because of unbounded concurrency #3271

Open
shivjm opened this issue May 1, 2024 · 1 comment · May be fixed by #3272
Open

[Performance] Writing templates is slow because of unbounded concurrency #3271

shivjm opened this issue May 1, 2024 · 1 comment · May be fixed by #3272

Comments

@shivjm
Copy link

shivjm commented May 1, 2024

Operating system

Windows 10

Eleventy

3.0.0-alpha.9

Describe the bug

This use of Promises:

await writeFile(outputPath, finalContent);

Means that almost all templates are written at the same time to the disk, which dramatically slows down individual writes. I added a console.time around the write to show this and recorded the output. You can see that some files take a full 15 seconds to write, and the total time for ‘Template Write’ is 15,885ms or nearly 16 seconds with 926 files.

For the sake of testing, I changed just that line to use fs.writeFileSync instead of await writeFile. Here’s the output. The time for ‘Template Write’ dropped to 232ms, with each individual file taking under a millisecond.

Reproduction steps

  1. Create multiple template files.
  2. Run Eleventy.

Expected behavior

Files are written sequentially or with bounded concurrency.

Reproduction URL

No response

Screenshots

No response

@shivjm
Copy link
Author

shivjm commented May 1, 2024

I think fixing this would also fix #2627.

shivjm added a commit to shivjm/eleventy that referenced this issue May 1, 2024
shivjm added a commit to shivjm/eleventy that referenced this issue May 1, 2024
shivjm added a commit to shivjm/eleventy that referenced this issue May 1, 2024
@shivjm shivjm linked a pull request May 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant