RelatedCollectionLinkNormalizer performance improved#6536
Conversation
carlobeltrame
left a comment
There was a problem hiding this comment.
Is the array return really faster than the exception? If so, then facepalm PHP...
But did you test whether the performance is also improved similarly with only the caching part?
api/src/Serializer/Normalizer/RelatedCollectionLinkNormalizer.php
Outdated
Show resolved
Hide resolved
As far as I know, it is faster in most languages if you don't need exceptions for the control flow. |
There was a problem hiding this comment.
When starting to write performance optimized code, there is always the tradeof between readability (here the inconsistency with the php way of writing code and that we use exceptions in the other places) and the gained performance.
A way for this would be:
- Benchmark this endpoint (measurement done)
- Show, that this is the crucial part were the performance can be gained, e.g. with a profiler. (Maybe there is a simpler place where we can gain more)
- optimize the performance here
- Benchmark again and show that it improved
- Write a test that enforces this maybe uncommon style
- Look how it behaves in production.
But i would say this is ok here and we look how the request time behaves when we have it running with real users against the real database.
But maybe there is more to gain with other configurations of the frankenphp container, as can be seen here:
api/src/Serializer/Normalizer/RelatedCollectionLinkNormalizer.php
Outdated
Show resolved
Hide resolved
api/src/Serializer/Normalizer/RelatedCollectionLinkNormalizer.php
Outdated
Show resolved
Hide resolved
api/src/Serializer/Normalizer/RelatedCollectionLinkNormalizer.php
Outdated
Show resolved
Hide resolved
api/src/Serializer/Normalizer/RelatedCollectionLinkNormalizer.php
Outdated
Show resolved
Hide resolved
|
@BacLuc |



Function
getRelatedCollectionHrefis called several times for the same relationOld:
New:
New2:
#6461