Skip to content

Conversation

@Gberzi01
Copy link
Contributor

Currently when the request returns a lot of items (for me it was 2.5k), the deserialisation process is really slow.

The issue seems to stem from O(n^2) loop, where for every item in the response, we again loop every item in the response.

The fix looks to resolve it by not redefining the includes for every item separately. This works as included is not mutated in the linkRelationships method. If there is fear of mutation, spread syntax or included.slice() could be used.

In my sample (large dataset, no relationships) the deserialisation process goes from taking 2 seconds to 2 ms.

@wopian wopian self-assigned this Jul 31, 2025
@wopian
Copy link
Owner

wopian commented Jul 31, 2025

Hi! Could you please rebase your PR onto the latest master?

The tests are currently failing because they rely on a test coverage service that has shutdown and has now been removed on master. Rebasing should resolve the issue.

@Gberzi01 Gberzi01 changed the base branch from master to 9.x August 1, 2025 06:54
@Gberzi01 Gberzi01 changed the base branch from 9.x to master August 1, 2025 06:54
@Gberzi01 Gberzi01 force-pushed the improve-deserialise-performance branch from 781a711 to 42d74fa Compare August 1, 2025 06:58
@Gberzi01
Copy link
Contributor Author

Gberzi01 commented Aug 1, 2025

Hello!

Rebased onto the latest master as requested.

@wopian wopian merged commit 6358253 into wopian:master Aug 4, 2025
8 of 9 checks passed
@wopian
Copy link
Owner

wopian commented Aug 4, 2025

Thank you! I'll get this rolled out to 10.x tomorrow hopefully 🙏

@wopian
Copy link
Owner

wopian commented Aug 7, 2025

Published as https://github.com/wopian/kitsu/releases/tag/v11.0.2

@Gberzi01 Gberzi01 deleted the improve-deserialise-performance branch August 10, 2025 21:16
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