Fix DomainMessage metadata bottleneck #69
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It turns out that adding metadata to a command or query is a serious bottleneck in our application because of the
toArray
andfromArray
transformations used in those methods. In our case it's about 10% of the total time the server needs to respond to a http request. The reason why it is a bottleneck is because the messages contain Ramsey\Uuid objects which are slow to convert to string and back. So I need to prevent this from happening.I've fixed it by changing the fromArray / toArray logic to simple PHP clone. Now this of course can be considered a BC break since the clone is no longer deep after this. I'm not exactly sure if this is a problem (it's not for me) so you need to consider the possible impacts before merging this. I'm fine with changing the logic on my side in case you don't want this change. Anyway I think you should know about this bottleneck and maybe consider some other changes to solve it.