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

Optimize dev edit-refresh loop by caching the highlighted files #1229

Merged
merged 5 commits into from
Oct 19, 2023

Conversation

AndrewJakubowicz
Copy link
Contributor

Issue: #1201

Context

This PR focusses exclusively on faster edit-refresh dev mode times.

Result is 11.3s edit-refresh time (from 16.7s edit-refresh time) on my M2 silicon mac.
Or, 34.4s edit-refresh time (from 57.3s ) on intel mac.

How

Instead of using the playwright browser process to always retrieve the syntax highlighted code, instead use a temporary dev cache so syntax highlighted code blocks can be retrieved from the file system.

This ends up being more optimal than running the code through the browser (even using synchronous file system calls).

Note: synchronous file system calls must be used as the whole API must be sync for 11ty.

Test plan

Manually tried it with edit refresh.
Note, there is a risk of a collision. In this case the code may appear wrong only in dev mode where caching is enabled.

This results in 11.3s edit-refresh time.
@github-actions
Copy link

github-actions bot commented Oct 18, 2023

A live preview of this PR will be available at the URL(s) below.
The latest URL will be appended to this comment on each push.
Each build takes ~5-10 minutes, and will 404 until finished.

https://pr1229-2993f53---lit-dev-5ftespv5na-uc.a.run.app/
https://pr1229-9756eb4---lit-dev-5ftespv5na-uc.a.run.app/
https://pr1229-691b88a---lit-dev-5ftespv5na-uc.a.run.app/
https://pr1229-c83234b---lit-dev-5ftespv5na-uc.a.run.app/
https://pr1229-4eb6adf---lit-dev-5ftespv5na-uc.a.run.app/

@AndrewJakubowicz AndrewJakubowicz marked this pull request as ready for review October 18, 2023 23:39
Copy link
Member

@augustjk augustjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a couple nits. This is awesome!

@AndrewJakubowicz AndrewJakubowicz merged commit eece220 into main Oct 19, 2023
13 of 15 checks passed
@AndrewJakubowicz AndrewJakubowicz deleted the blocking-render-dev-optimization branch October 19, 2023 01:25
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.

2 participants