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

Write templates synchronously #3272

Merged
merged 1 commit into from
Jun 10, 2024

Conversation

shivjm
Copy link
Contributor

@shivjm shivjm commented May 1, 2024

I’m not sure how to implement a queue to resolve #3271 but here’s my proposed workaround. This does block everything while writing a template (hopefully a small window).

Closes #3271
Closes #2627

@shivjm
Copy link
Contributor Author

shivjm commented May 20, 2024

@uncenter pointed out that the Fetch and Image plugins use the p-queue library. I think I’ll add a commit to this PR using p-queue; if it’s not desirable, I can back it out.

@shivjm shivjm marked this pull request as draft May 20, 2024 06:36
@shivjm shivjm force-pushed the write-templates-synchronously branch from 72ab568 to b02eb19 Compare May 20, 2024 12:19
@zachleat
Copy link
Member

zachleat commented Jun 10, 2024

I’m okay with trying this out in 3.0.0-alpha.11.

Preliminary benchmarking suggests that the performance cost is about the same here:

---------------------------------------------------------
Eleventy Benchmark (Node v20.12.2, 10000 templates each)
---------------------------------------------------------
Eleventy 3.0.0-alpha.10                                        
---------------------------------------------------------
.md: ... 3 runs:              
* Median: 7.92 seconds
* Median per template: 792 µs

---------------------------------------------------------
Eleventy 3.0.0-alpha.11                                        
---------------------------------------------------------
.md: ... 3 runs:              
* Median: 8 seconds (1%)
* Median per template: 800 µs (1%)

@zachleat zachleat marked this pull request as ready for review June 10, 2024 20:00
@zachleat
Copy link
Member

zachleat commented Jun 10, 2024

Somewhat related (but for the rendering pipeline, not file writing): #3277.

Happy to entertain some other queuing additions here if we think it would be helpful! Though https://www.npmjs.com/package/graceful-fs does some of this already!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants