Skip to content
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

Partially rewrite JsonApi\Hydrator to improve performance #18

Merged
merged 1 commit into from
Jun 1, 2018

Conversation

JaZo
Copy link
Member

@JaZo JaZo commented Jun 1, 2018

Description

I (partially) rewrote the JsonApi\Hydrator to improve the performance.

Motivation and context

Hydrating a document with 2.000 items with relationships took about five minutes. After this change it is reduced to around two seconds. 🎉

Performance was improved by using a 'lookup table' to find the hydrated items instead of looping over all items for every relationship e.g. 2.000 * 2.000.

How has this been tested?

This has been tested/profiled in a private project with timings from laravel-debugbar. Please see this example json.

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read the CONTRIBUTING document.
  • My pull request addresses exactly one patch/feature.
  • I have created a branch for this patch/feature.
  • Each individual commit in the pull request is meaningful.
  • I have added tests to cover my changes.
  • If my change requires a change to the documentation, I have updated it accordingly.

@bbrala
Copy link
Member

bbrala commented Jun 1, 2018

Awesome! Glad the lookup table worked out so well 👍

@JaZo JaZo merged commit ef62078 into master Jun 1, 2018
@JaZo JaZo deleted the improve-hydrator-performance branch June 1, 2018 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants