Goal
Reduce checkout/provisioning latency for template-based site creation by optimizing MUCD_Data::copy_data() usage in the site duplicator.
Context
During the sovereign tenant checkout regression fix, profiling showed the publish path now starts immediately and sovereign isolation itself is not the bottleneck. The remaining slow portion is template duplication:
- queued publish total: about 6.56s
- duplicator total: about 5.93s
MUCD_Data::copy_data(): about 3.48s
wpmu_create_blog: about 1.86s
- sovereign provider total: about 1.43s
The profiled template had 104 wp_2_* tables, 80 of them empty, and about 9.16 MB total data. Copying empty/runtime tables dominates avoidable work.
Files / patterns to inspect
inc/helpers/class-site-duplicator.php
- Current pattern calls
MUCD_Data::copy_data() for template table duplication.
- Add filtering/skipping before copy, or wrap the call with a smarter table selection strategy if the upstream duplicator supports it.
inc/models/class-site.php
- Existing profiling around site save/template duplication can be reused for before/after timing.
Proposed approach
- Skip empty template tables when duplicating a site.
- Exclude or defer runtime-only tables where safe, especially analytics/cache/log/action-scheduler-style tables that do not need to be cloned into a new customer site.
- Keep behavior conservative for content/config tables; do not drop data needed for a faithful template clone.
- Preserve existing hooks/filters so extensions can opt tables in/out.
Acceptance criteria
- New template sites still contain required WordPress/content/config tables and load successfully.
- Empty template tables are not copied when safe.
- Runtime-only tables are excluded or explicitly deferred with a documented allow/deny list.
- Profiling shows
copy_data and total queued publish time decrease on the same template.
- Regression tests cover table-selection behavior and prevent copying clearly empty/runtime tables unintentionally.
Verification
- Run the existing PHP syntax/style checks for changed files.
- Run targeted duplicator/site tests or add tests if coverage is missing.
- In a dev multisite with profiling enabled, create a template-based site and compare
um_duplicator.copy_data timing before/after.
- Manually verify the created site loads and has expected copied content/settings.
Notes
- This is a performance follow-up, not part of the sovereign publish correctness fix.
- Avoid changing the newly added sovereign queued-publish behavior unless a test proves it is required.
aidevops.sh v3.20.12 plugin for OpenCode v1.15.13 with gpt-5.5
Goal
Reduce checkout/provisioning latency for template-based site creation by optimizing
MUCD_Data::copy_data()usage in the site duplicator.Context
During the sovereign tenant checkout regression fix, profiling showed the publish path now starts immediately and sovereign isolation itself is not the bottleneck. The remaining slow portion is template duplication:
MUCD_Data::copy_data(): about 3.48swpmu_create_blog: about 1.86sThe profiled template had 104
wp_2_*tables, 80 of them empty, and about 9.16 MB total data. Copying empty/runtime tables dominates avoidable work.Files / patterns to inspect
inc/helpers/class-site-duplicator.phpMUCD_Data::copy_data()for template table duplication.inc/models/class-site.phpProposed approach
Acceptance criteria
copy_dataand total queued publish time decrease on the same template.Verification
um_duplicator.copy_datatiming before/after.Notes
aidevops.sh v3.20.12 plugin for OpenCode v1.15.13 with gpt-5.5