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

Reducing the number of paths of remote-change event #266

Closed
hackerwins opened this issue Jan 6, 2022 · 3 comments · Fixed by #351
Closed

Reducing the number of paths of remote-change event #266

hackerwins opened this issue Jan 6, 2022 · 3 comments · Fixed by #351
Labels
enhancement 🌟 New feature or request

Comments

@hackerwins
Copy link
Member

hackerwins commented Jan 6, 2022

Description:

Reducing the number of paths of remote-change events.

Changes to the document are propagated to peers as remote-change events.
When inserting nested objects, there is a problem that the path becomes excessively large.

For example, inserting a nested object into one field will create paths for remote-change like this:

clientA inserts nested object.

doc.update((root) => {
  root.projects = [{
    id: 'id7fb51ad',
    _timestamp: 1641431282095,
    _time:834.9000000357628,
    visible:true,
    lock:false,
    selected:false,
    layers":[{
    ...
  }]
});

Currently clientB receives remote-change event.

{
  type: 'remote-change'
  value: {
    paths: [
      '$.projects',
      '$.projects.0',
      '$.projects.0.id',
      '$.projects.0._timestamp',
      '$.projects.0._time',
      '$.projects.0.visible',
      '$.projects.0.lock',
      '$.projects.0.selected',
      '$.projects.0.layers',
      '$.projects.0.layers.0',
      ...
    ]
  }
}

We can reduce paths by leaving only the top-level path when the nested object changes.

{
  type: 'remote-change'
  value: {
    paths: ['$.projects']
  }
}

Why:

Excessive accumulation of paths can lead to unnecessary resource usage.

@hackerwins hackerwins added the enhancement 🌟 New feature or request label Jan 6, 2022
@hunkim98
Copy link
Contributor

✋ May I try this out? I have experienced this nuisance when creating a yorkie example on my own.

@hackerwins
Copy link
Member Author

@hunkim98 Sure. 👍

@hackerwins hackerwins reopened this Sep 21, 2023
@hackerwins hackerwins mentioned this issue Sep 21, 2023
2 tasks
hackerwins added a commit that referenced this issue Sep 21, 2023
Trie was initially introduced to reduce the number of events from a
common ancestor(#351). However, it was later removed during the
implementation of the topic subscribe feature(#487, #566).

For now, I'll remove unused Trie and reopen the event-reducing issue
again(#266).
@hackerwins
Copy link
Member Author

This was solved by #691.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🌟 New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants