Overview

With a cold cache xb/api/v0/config/component takes upwards of 5 seconds to load on my local environment

Profiling it with SPX I see 11.48 Million ‼️ function calls with a wall time of 8.77s

Proposed resolution

Improve the performance of this endpoint as the XB UI doesn't work until it has been loaded - we block loading the component and page data forms until it has finished.

Looks like some things we could optimise are in the shape matcher - \Drupal\experience_builder\ShapeMatcher\FieldForComponentSuggester::suggest in particular as the entry point

- Drupal\Core\Entity\TypedDat…tyDataDefinition::getBundles - 137k calls from \Drupal\experience_builder\ShapeMatcher\JsonSchemaFieldInstanceMatcher::findFieldInstanceFormatMatches

User interface changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

larowlan created an issue. See original summary.

larowlan’s picture

Issue summary: View changes

.

larowlan’s picture

Status: Active » Needs review

This was causing cypress fails for me locally due to the time out.

MR improves performance by 80%

larowlan’s picture

Title: Improve performance of /xb/api/v0/config/component » Improve performance of /xb/api/v0/config/component by 80%

Salacious title update

wim leers’s picture

Yep, I knew this: #3515510-2: Improve backend API performance: add caching to shape matching 👈 that's why I moved it to the Shape matching issue queue component :) This essentially does exactly what I intended 😃

wim leers’s picture

There's plenty more low-hanging fruit, see https://git.drupalcode.org/project/experience_builder/-/merge_requests/1....

There's also #3503038: Enable candidate `DynamicPropSource` suggestions for code components: refactor `GeneratedFieldExplicitInputUxComponentSourceBase` and `FieldForComponentSuggester` to need only SDC's ComponentMetadata, not SDC plugin instances to decouple this from SDCs.

But here's the real kicker: we don't need any of this until a ContentTemplate UI exists! So I've been wanting to remove dynamic_prop_sources from the /xb/api/v0/config/component response for a good while. Which is why #3510896: Add a new internal HTTP API for candidate `DynamicPropSource`s to enable a `ContentTemplate` UI has been assigned to me for months. That will simply remove these computations from the critical path!

Because the ContentTemplate UI should be able to just request the candidate dynamic prop sources on a per-content entity-t bundle basis. There's never a need to list them all across all entity types/bundles — I did that only for early PoC/testing purposes!

wim leers’s picture

Title: Improve performance of /xb/api/v0/config/component by 80% » Optimize DynamicPropSource candidate suggestion logic: improves performance of /xb/api/v0/config/component by 80%
Assigned: wim leers » Unassigned
Status: Needs review » Reviewed & tested by the community
wim leers’s picture

Status: Reviewed & tested by the community » Fixed

  • wim leers committed 6890e9a6 on 0.x authored by larowlan
    Issue #3530907 by larowlan, wim leers: Optimize DynamicPropSource...
wim leers’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.