We have 350 entities at the moment, and on one of our simple APIs (an insert on a non audited entity), it takes a lot of time. After investigation, I believe the issue is within this bundle. It might be because I missed a configuration option, but I wanted to raise the problem we're having.
Current behavior
When doing a simple insert task on the database, the audit bundle loads all metadata and parses all entities to look for auditable entities in order to satisfy the condition "isAudited()" here :
foreach (array_reverse($uow->getScheduledEntityInsertions()) as $entity) {
if ($this->provider->isAudited($entity)) {
This is particularly heavy on our projects, and a simple "insert" call on a "ping" API takes a lot of time, on an entity that isn't even audited.
How to reproduce
Have a project with many entities, create a non audited Entity, persist it, and monitor how long the flush takes, and especially the load function in DH\Auditor\Provider\Doctrine\Auditing\Annotation\AnnotationLoader, that should make up most of the "flush" time.
public function load(): array
{
$configuration = [];
$metadatas = $this->entityManager->getMetadataFactory()->getAllMetadata();
foreach ($metadatas as $metadata) {
$config = $this->getEntityConfiguration($metadata);
if (null !== $config) {
$configuration[$metadata->getName()] = $config;
}
}
return $configuration;
}
Expected behavior
I would expect the metadatas to be cached like the ones from Doctrine if we set up the cache driver. In production mode, they shouldn't change.
I'd make a pull request if I was sure that the problem is here and how to fix it "properly". (cache configuration ? load everything only if at least one of our entities is auditable ? ...)
auditor-bundle
versionSummary
We have 350 entities at the moment, and on one of our simple APIs (an insert on a non audited entity), it takes a lot of time. After investigation, I believe the issue is within this bundle. It might be because I missed a configuration option, but I wanted to raise the problem we're having.
Current behavior
When doing a simple insert task on the database, the audit bundle loads all metadata and parses all entities to look for auditable entities in order to satisfy the condition "isAudited()" here :
This is particularly heavy on our projects, and a simple "insert" call on a "ping" API takes a lot of time, on an entity that isn't even audited.
How to reproduce
Have a project with many entities, create a non audited Entity, persist it, and monitor how long the flush takes, and especially the load function in DH\Auditor\Provider\Doctrine\Auditing\Annotation\AnnotationLoader, that should make up most of the "flush" time.
Expected behavior
I would expect the metadatas to be cached like the ones from Doctrine if we set up the cache driver. In production mode, they shouldn't change. I'd make a pull request if I was sure that the problem is here and how to fix it "properly". (cache configuration ? load everything only if at least one of our entities is auditable ? ...)