Skip to content

Conversation

Ldoppea
Copy link
Member

@Ldoppea Ldoppea commented Feb 28, 2025

No description provided.

paultranvan and others added 8 commits February 25, 2025 15:29
We used to hydrate any document with the relationships existing in the
provided schema, even though the relationship does not exist on the
document. We now hydrate only if the relationship is set in the
document.
Note we can still force the hydratation through a `forceHydration`
option, to ease migrations on apps with many relations.

BREAKING CHANGE: the relationship hydration is made only if the
relationship exists in the document, so the developer should not assume
a `document.relationshipName` is always defined, anymore.
As an alternative, it is now possible to pass `forceHydration` on
cozy-client options to ease migration.
However, please not this has performance impact, as it forces
extra-check on store queries evaluation.
@Ldoppea Ldoppea force-pushed the feat/performance_improvements branch from ee55d23 to 5807df1 Compare February 28, 2025 19:15

return false
})
for (const document of documentsToPersist) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really better? OK you don't call a method if not needed, but now you loop twice

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually significantly better. After a big query retrieving 25K docs, the persistVirtualDocuments takes:

  • Before: 609ms
  • After: 20ms

I wonder if this is because of the event loop overwhelmed by too many calls

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh shit, I didn't saw that the persistVirtualDocument was async... This is why.

nit: You can now remove the check within the persistVirtualDocument method since should only call it with the docs to persist ^^.

if (normalizedDoc.rev) {
delete normalizedDoc.rev
if (doc.rev) {
delete doc.rev
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setting to undefined is way more performant than calling delet(https://jsperf.app/delete-vs-undefined-vs-null/10 I don't like the void 0 stuff)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know! I did the change in another PR: 2b89a63

@paultranvan paultranvan force-pushed the fix-store-documents-updates branch 6 times, most recently from a2bc4d0 to 9e79d2c Compare March 10, 2025 10:49
@paultranvan
Copy link
Contributor

This PR has been replaced by: #1596

@paultranvan paultranvan force-pushed the fix-store-documents-updates branch 5 times, most recently from db2aabf to b0714ba Compare March 11, 2025 17:03
Base automatically changed from fix-store-documents-updates to master March 11, 2025 17:40
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.

3 participants