eleventy
eleventy copied to clipboard
[Performance] Writing templates is slow because of unbounded concurrency
Operating system
Windows 10
Eleventy
3.0.0-alpha.9
Describe the bug
This use of Promises:
https://github.com/11ty/eleventy/blob/9c3a7619a429f26cc2b449d65209be6d6a23828e/src/Template.js#L751
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
- Create multiple template files.
- Run Eleventy.
Expected behavior
Files are written sequentially or with bounded concurrency.
Reproduction URL
No response
Screenshots
No response
I think fixing this would also fix #2627.
Shipping your PR with 3.0.0-alpha.11