ux icon indicating copy to clipboard operation
ux copied to clipboard

[TwigComponent] Centralize, reuse and warm-up component properties metadata [WIP]

Open smnandre opened this issue 1 year ago • 4 comments

Currently if we have 50 times the same component in a page, 50 times we use reflection to analyse component class properties and methods.

This PR centralize this task in a dedicated (internal) service and add a cachewarmer to pre-compute metadata during app build.

Significant performance gains here too (i won't do charts for every PR but be sure i'm gonna make some before/after once i'm "done" with all this.... in Vienna 👼 )

smnandre avatar Sep 26 '24 11:09 smnandre

As an alternative, or even as a follow-up, I think it makes sense to replace/improve class ComponentMetadata. We could get all possible meta information PostMount/PreMount/ExposeInTemplate hooks etc, not just about properties.

Structure may look like this: ComponentMetadata - store metadata ComponentMetadataFactory - provider metadata with methods getMetadataFor/hasMetadataFor. Factory methods return ComponentMetadata instance. ComponentCacheWarmer - cache warmer call factory ComponentMetadataFactory

onEXHovia avatar Sep 27 '24 07:09 onEXHovia

Hey @onEXHovia ! You read my mind

This is indeed my next move, and i started to extract the props metadata from template too :)

smnandre avatar Sep 27 '24 22:09 smnandre

Are we agree, this is happening only in prod ?

@WebMamba nothing "prod-related"

For all the environments, during a request, there is no need to compute metadata twice, so the values are "kept".

Also, if you use cache:warm all the components metadata are cached in the ssytem cache.

What's maybe missing here is something to invalidate the cache locally if you change a file ?

Do you have encountered any trouble ?

smnandre avatar Sep 27 '24 22:09 smnandre

image

A small rebase before merging? :) 🙏🏻

Kocal avatar Sep 29 '24 11:09 Kocal