Skip to content

Conversation

@bcotrim
Copy link
Contributor

@bcotrim bcotrim commented Oct 3, 2025

Related issues

Proposed Changes

  • During createSite store setup steps in a blueprint to run at first site start. This will avoid having to run Playground CLI twice (once for run-blueprint and another for server)
  • Made thumbnail generation async
  • Fixed race-condition in the UI, to make the creating site component display until startSite is done.
  • Created Studio Admin API mu-plugin with persistent endpoints that reuse the already-loaded WordPress instance, avoiding the overhead of loading wp-load.php multiple times:
    • get_theme_details endpoint - Retrieves active theme information without loading WordPress
    • set_admin_password endpoint - Sets/updates admin user password without loading WordPress
  • Added request() method to Playground CLI server process to communicate with persistent WordPress instance via HTTP requests
  • Added fallback logic in phpGetThemeDetails to support WP-Now provider (uses runPhp() when request() is not available)

Testing Instructions

  • As much tests as possible around, creating, starting, stopping, importing and exporting sites (including sync and preview sites)

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@bcotrim bcotrim self-assigned this Oct 3, 2025
@bcotrim bcotrim requested review from a team and sejas October 3, 2025 16:16
@bcotrim bcotrim marked this pull request as ready for review October 3, 2025 16:17
@bcotrim bcotrim changed the title Perf/optimize site startup Studio: Improve performance for create site Oct 3, 2025
Copy link
Member

@sejas sejas left a comment

Choose a reason for hiding this comment

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

Great refactor. I reviewed the code, and suggested a few improvement on Blueprint types. I also tested the app and only found these errors:

  • The Stop all button on the left sidebar doesn't work.
  • The creation site notification appears too early and not after the site is created.
  • I tested it on Windows using Parallels and it took a while to create the site and it render the wp-admin.
windows-slow.mp4

@bcotrim bcotrim marked this pull request as draft October 4, 2025 13:34
@bcotrim bcotrim marked this pull request as ready for review October 5, 2025 11:55
Copy link
Member

@sejas sejas left a comment

Choose a reason for hiding this comment

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

@bcotrim , thanks for applying the suggestions.
I tested the app on Mac and WIndows and I didn't catch any regression. I was able to create a site using a local blueprint and also a blank site.

Windows is still slower than Mac, but the problem seems to come from the playground-cli boot process.

Here are the logs for both platforms:

MAC

Would have bumped stat: studio-app-site-create=file-blueprint
Starting server for 'blue git'
[playground-cli] [+10.81ms | Total: 10.81ms] The fs-ext package is not installed. Internal file locking will not be integrated with host OS file locking.
[playground-cli] [+0.90ms | Total: 11.71ms] Starting a PHP server...
[playground-cli] [+5.48ms | Total: 17.19ms] Setting up WordPress latest
[playground-cli] [+698.12ms | Total: 715.30ms] Resolved WordPress release URL: https://downloads.w.org/release/wordpress-6.8.3.zip
[playground-cli] [+8.96ms | Total: 724.27ms] Fetching SQLite integration plugin...
[playground-cli] [+1.01ms | Total: 725.28ms] Booting WordPress...
PHP.request() is deprecated. Please use new PHPRequestHandler() instead.
[playground-cli] [+4374.35ms | Total: 5099.63ms] Booted!
[playground-cli] [+0.62ms | Total: 5100.25ms] Running the Blueprint...
Logging in – 100%
[playground-cli] [+2957.13ms | Total: 8057.38ms] Finished running the blueprint
[playground-cli] [+0.17ms | Total: 8057.55ms] WordPress is running on http://127.0.0.1:8887 with 1 worker(s)
Server started for 'blue git'

Window Logs

Would have bumped stat: studio-app-site-create=no-blueprint
Starting server for 'windows blank site'
[playground-cli] [+29.98ms | Total: 29.98ms] Starting a PHP server...
[playground-cli] [+35.95ms | Total: 65.93ms] Setting up WordPress latest
[playground-cli] [+1412.18ms | Total: 1478.11ms] Resolved WordPress release URL: https://downloads.w.org/release/wordpress-6.8.3.zip
[playground-cli] [+104.38ms | Total: 1582.49ms] Fetching SQLite integration plugin...
[playground-cli] [+5.21ms | Total: 1587.69ms] Booting WordPress...
PHP.request() is deprecated. Please use new PHPRequestHandler() instead.
[playground-cli] [+60377.93ms | Total: 61965.63ms] Booted!
[playground-cli] [+6.61ms | Total: 61972.24ms] Running the Blueprint...
Running the Blueprint ΓÇô 0%
Running the Blueprint ΓÇô 1%
Running the Blueprint ΓÇô 33%
Running the Blueprint ΓÇô 34%
Running the Blueprint ΓÇô 35%
Running the Blueprint ΓÇô 36%
Running the Blueprint ΓÇô 37%
Running the Blueprint ΓÇô 38%
Running the Blueprint ΓÇô 39%
Running the Blueprint ΓÇô 40%
Running the Blueprint ΓÇô 41%
Running the Blueprint ΓÇô 42%
Running the Blueprint ΓÇô 43%
Running the Blueprint ΓÇô 44%
Running the Blueprint ΓÇô 45%
Running the Blueprint ΓÇô 46%
Running the Blueprint ΓÇô 47%
Running the Blueprint ΓÇô 48%
Running the Blueprint ΓÇô 49%
Running the Blueprint ΓÇô 50%
Running the Blueprint ΓÇô 51%
Running the Blueprint ΓÇô 52%
Running the Blueprint ΓÇô 53%
Running the Blueprint ΓÇô 54%
Running the Blueprint ΓÇô 55%
Running the Blueprint ΓÇô 56%
Running the Blueprint ΓÇô 57%
Running the Blueprint ΓÇô 58%
Running the Blueprint ΓÇô 59%
Running the Blueprint ΓÇô 60%
Running the Blueprint ΓÇô 61%
Running the Blueprint ΓÇô 62%
Running the Blueprint ΓÇô 63%
Running the Blueprint ΓÇô 64%
Running the Blueprint ΓÇô 65%
Running the Blueprint ΓÇô 66%
Logging in ΓÇô 66%
Logging in ΓÇô 100%
[playground-cli] [+4578.10ms | Total: 66550.34ms] Finished running the blueprint
[playground-cli] [+3.50ms | Total: 66553.85ms] WordPress is running on http://127.0.0.1:8892 with 1 worker(s)
Server started for 'windows blank site'
-13536-cNMUjMeNvJEY
Deleted stale Playground temp dir: C:\Users\MACBOO~1\AppData\Local\Temp\electron.exe-playground-cli-site-14560--14560-Xnz3PrPc4Mif
-13536-cNMUjMeNvJEY
-13536-cNMUjMeNvJEY
Deleted stale Playground temp dir: C:\Users\MACBOO~1\AppData\Local\Temp\electron.exe-playground-cli-site-14560--14560-Xnz3PrPc4Mif
-13536-cNMUjMeNvJEY
Deleted stale Playground temp dir: C:\Users\MACBOO~1\AppData\Local\Temp\electron.exe-playground-cli-site-14560--14560-Xnz3PrPc4Mif
Deleted stale Playground temp dir: C:\Users\MACBOO~1\AppData\Local\Temp\electron.exe-playground-cli-site-8832--8832-WxdxW0O4mj9b
Deleted stale Playground temp dir: C:\Users\MACBOO~1\AppData\Local\Temp\electron.exe-playground-cli-site-17108--17108-SNpZ3zooZ0oC
-13536-cNMUjMeNvJEY
Deleted stale Playground temp dir: C:\Users\MACBOO~1\AppData\Local\Temp\electron.exe-playground-cli-site-14560--14560-Xnz3PrPc4Mif
Deleted stale Playground temp dir: C:\Users\MACBOO~1\AppData\Local\Temp\electron.exe-playground-cli-site-8832--8832-WxdxW0O4mj9b
-13536-cNMUjMeNvJEY
Deleted stale Playground temp dir: C:\Users\MACBOO~1\AppData\Local\Temp\electron.exe-playground-cli-site-14560--14560-Xnz3PrPc4Mif
Deleted stale Playground temp dir: C:\Users\MACBOO~1\AppData\Local\Temp\electron.exe-playground-cli-site-8832--8832-WxdxW0O4mj9b
Deleted stale Playground temp dir: C:\Users\MACBOO~1\AppData\Local\Temp\electron.exe-playground-cli-site-17108--17108-SNpZ3zooZ0oC
Deleted stale Playground temp dir: C:\Users\MACBOO~1\AppData\Local\Temp\electron.exe-playground-cli-site-15180--15180-G00mNJ9sszRQ
Deleted stale Playground temp dir: C:\Users\MACBOO~1\AppData\Local\Temp\electron.exe-playground-cli-site-3480--3480-U9vpYFPwpJQ5
Deleted stale Playground temp dir: C:\Users\MACBOO~1\AppData\Local\Temp\electron.exe-playground-cli-site-4064--4064-aKbQlfpJhYgE

@bcotrim bcotrim merged commit 789542b into trunk Oct 6, 2025
12 checks passed
@bcotrim bcotrim deleted the perf/optimize-site-startup branch October 6, 2025 09:50
@youknowriad
Copy link
Contributor

This definitely improved performance, you can see it on Code vitals on the site creation metric https://www.codevitals.run/project/studio/siteCreation

We're now back to similar performance levels to pre playwright CLI enabling.

@wojtekn
Copy link
Contributor

wojtekn commented Oct 7, 2025

Thanks for checking and sharing @youknowriad - introducing those performance tests was a good idea!

@youknowriad
Copy link
Contributor

haha thanks, let's keep an eye on them. They're only useful if we pay attention to them though :P
One good follow-up there maybe would be a comment on PRs if the diff is too high or something.

@wojtekn wojtekn mentioned this pull request Oct 7, 2025
1 task
@adamziel
Copy link

adamziel commented Oct 9, 2025

Really nice work here! 🎉

A few thoughts I had about Mac logs:

[playground-cli] [+35.95ms | Total: 65.93ms] Setting up WordPress latest
[playground-cli] [+1412.18ms | Total: 1478.11ms] Resolved WordPress release URL

This time is mostly spent on translating 6.8 to a WordPress release URL, it's interesting this takes 1.5 seconds – it's mostly a memoized request to https://api.wordpress.org/core/version-check/1.7/?channel=beta. time curl https://api.wordpress.org/core/version-check/1.7/?channel=beta gives me around 500ms consistently, I wonder if that's just a connection thing or is there anything else going on.

[playground-cli] [+1.01ms | Total: 725.28ms] Booting WordPress...
PHP.request() is deprecated. Please use new PHPRequestHandler() instead.
[playground-cli] [+4374.35ms | Total: 5099.63ms] Booted!

This is the time needed to spawn a worker and run the WordPress installation wizard. We could likely cache a vanilla WordPress installation to save a bit time here, although we'd pay the price in complexity. Starting a new site from that "preinstalled template" would require rewriting URLs and likely other database records – https://playground.wordpress.net/ used to do that and it was faster, but it was also error-prone. Now we just run the installation wizard every time until we have a full site importing pipeline.

[playground-cli] [+0.62ms | Total: 5100.25ms] Running the Blueprint...
Logging in – 100%
[playground-cli] [+2957.13ms | Total: 8057.38ms] Finished running the blueprint

Not sure what's in the Blueprint but 3 seconds seems pretty cool. I'm happy to discuss any perf improvements here if you think there's a room for that.

@adamziel
Copy link

adamziel commented Oct 9, 2025

About the windows logs – this is such a long, looong time. Is this with the windows security layer exception added to prevent it from slowing down the process?

@bcotrim
Copy link
Contributor Author

bcotrim commented Oct 10, 2025

About the windows logs – this is such a long, looong time. Is this with the windows security layer exception added to prevent it from slowing down the process?

I have the Windows security layer exception and noticed similar times. Disabling the Windows security also didn't help, from my testing.

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.

6 participants