-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RelatedCollectionLinkNormalizer performance improved #6536
RelatedCollectionLinkNormalizer performance improved #6536
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
getRelatedCollectionHref
is called several times for the same relationOld:
New:
New2:
#6461