[TYPO3-core] Extbase validation, lazy loading and performance

Helmut Hummel helmut.hummel at typo3.org
Fri Nov 8 09:27:05 CET 2013


Hi Nico,

On 08.11.13 09:09, Nicolas de Haen wrote:

> I tested 6.2-dev with a complex extbase application and found the number
> of queries and function calls 3 times higher than with 6.1.5.
>
> I could trace it down to the recursive validation (introduced in
> https://review.typo3.org/#/c/21428/).
> It loops recursive through the whole model and calls properties for
> validation, which were not called in 6.1.5 (they are annotated as @lazy).

So far, this is expected behaviour I would say.

> Additionally there seems to be an issue that recurrence of the same
> object in different relations is not recognized.

Hm, there is code in place to prevent that:

protected function isValidatedAlready($object) {
	if ($this->validatedInstancesContainer === NULL) {
		$this->validatedInstancesContainer = new \SplObjectStorage();
	}
	if ($this->validatedInstancesContainer->contains($object)) {
		return TRUE;
	} else {
		$this->validatedInstancesContainer->attach($object);

		return FALSE;
	}
}

But it might be the case that there are some issues if an object is 
loaded lazily at one place and eager on another place and the resulting 
objects not being the same.

> So if you have a model like: Project m:n Teams m:n Members it results in
> a lot of queries, if you call the show action for one project.

That is very easy to fix by annotating @ignorevalidation for your show 
action.

Doing so, I would consider as best practice, combined with some 
initialisation that disallows object modification in the property 
mapper, so that only persistent objects can be passed to this action.

> Concerning the discussed performance tests, it might be a good idea to
> have some kind of reference extbase extension/package which can be
> tested during development.
>
> I think there is a high demand anyway, to have an up-to-date, best
> practice example for an extbase extension/package.
 > PS: sugestion for the package: maybe a bit complexer than the blog
 > example, what about a football package with teams, players, competitions
 > and example data?
 > FC Bigfoot would be back again!

That would indeed be great.

> It would also help
> me, to keep the ExtensionBuilder up to date (I'm planning a new release
> for 6.2)

Thanks for that!

Kind regards,
Helmut

-- 
Helmut Hummel
Release Manager TYPO3 6.0
TYPO3 Core Developer, TYPO3 Security Team Member

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the TYPO3-team-core mailing list