-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Env: Only perform expensive install work when required #23809
Conversation
Size Change: +91 B (0%) Total Size: 1.14 MB
ℹ️ View Unchanged
|
d50ba1e
to
5e2ab85
Compare
@epiqueras do you know if we need run the WordPress configuration code again if the WordPress source updates? Currently, if it does a |
I guess it depends on the nature of the changes that have been pulled in. |
Hm. What if:
|
That makes more sense. People might not want to update sometimes too. |
Makes sense. Added in c36e22d. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spent a good amount of time wrapping my head around the wp-env
package. Definitely not an expert, but the caching logic looks reasonable.
I can also confirm that:
- the cache is busted when
.wp-env.json
options change - the performance is blazing fast 🔥
I'm having trouble verifying that adding the --update flag busts the cache though.
if it takes > 2 seconds then it should be re-configuring wp. In Gutenberg, you can also verify by noting that it shows "downloading WordPress" for a brief moment before continuing (if it is already up to date) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it takes > 2 seconds then it should be re-configuring wp. In Gutenberg, you can also verify by noting that it shows "downloading WordPress" for a brief moment before continuing (if it is already up to date)
My mistake. I should clarify. When I said "I'm having trouble verifying", I meant that I wasn't able to force the longer load times. Passing the --update flag didn't lead to expected behavior.
@jeyip oh, interesting! Here's a gif of what it does for me: |
@noahtallen Let me try again. I'll keep you updated. |
🤔 🤔 🤔 🤔 🤔 🤔 🤔 🤔 🤔 |
That's confusing, since both should ultimately be accessing |
@jeyip I figured it out actually 😅 If you run |
Oh I see! Thanks for helping debug that. This seems like user error since npm documents the extra -- pretty clearly. Everything else looks good to me 🎉 |
- add --update flag to force update - add cache lib to store config checksum - only run update if checksum changed
7924729
to
9e9606e
Compare
Description
TLDR: wp-env start only takes 1-2 seconds in common use cases.
wp-env start
is now much lazier, only doing time-intensive work when required.wp-env
previously did the following actions on every run:wp core install
andwp config set
)Now, these actions are only performed in two situations:
*.wp-env.json
files, and when different environment variables change.)--update
flag.To accomplish this, I added a little library to read/write cache values to a cache JSON file stored in the wp-env work directory. This might be useful in the future, particularly if we want to get more granular about this behavior.
Note that the WordPress install and source downloads still happen each run so that they stay up-to-date.
How has this been tested?
Locally, in wp-env; CI should work. You can test with
npx wp-env start
locally with this branch checked out and it will run sourcecode.Screenshots
The first run is before this change. The second is with this improvement:
Types of changes
Performance improvement
Checklist: