-
Notifications
You must be signed in to change notification settings - Fork 323
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
Persist a subset of IdMap #10347
Persist a subset of IdMap #10347
Conversation
Please QA |
} | ||
const newMetadataJson = newMetadata && json.stringify(metadataToPersist) | ||
const idMapToPersist = | ||
newIdMap && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition is no longer accurate: A new idMapToPersist
needs to be computed if the ID map changes or if the metadata changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the metadata line changes, the IdMap will be recomputed as well. And if the metadata was changed without changing the IDs, we don't need to edit the IdMap section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the metadata line changes, the IdMap will be recomputed as well.
I don't see this being enforced in the ydoc-server. If you mean it will be recomputed at the same time in the GUI, the ydoc-server should not depend on that.
When adding a new node, first the new node is committed then its position is computed. In the interim, the node usually doesn't have any non-default metadata; if we are always writing node metadata at the same time that a node is added, that's an inefficiency we should be able to fix in the GUI without the ydoc-server causing data loss.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed a problem. There needs to be a check if newMetadata
contains a new key. At the minimum, This could be (newIdMap || newMetadata) &&
, effectively always writing ID Map when any metadata changes. That could be further optimized later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see that applyDocumentUpdates
enso/app/gui2/ydoc-server/languageServerSession.ts
Lines 451 to 455 in 305f69c
const { newCode, newIdMap, newMetadata } = applyDocumentUpdates( | |
this.doc, | |
synced, | |
moduleUpdate, | |
) |
recomputes IdMap from the
root
ASTenso/app/gui2/ydoc-server/edits.ts
Lines 67 to 74 in 305f69c
const syncModule = new MutableModule(doc.ydoc) | |
const root = syncModule.root() | |
assert(root != null) | |
if (codeChanged || idsChanged || synced.idMapJson == null) { | |
const { code, info } = print(root) | |
if (codeChanged) newCode = code | |
newIdMap = spanMapToIdMap(info) | |
} |
or am I reading that wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition codeChanged || idsChanged || synced.idMapJson == null
can still be false when existing metadata structure updates. In that situation a new ID will have to be stored while no code was actually changed.
Currently, all metadata is written on expressions that also happen to be node roots, so it kinda works out. But this is not a limitation of the system that we are willing to have, since we are soon going to add metadata to individual expressions. That will be needed to store persistent widget state. Those expressions will already exist when we adjust the widget data, effectively sending a delaying metadata update without any code changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- the direction looks good
- having some unit test would make the change more robust for the future
- what is the effect on size of IdMap of some well known example?
Pull Request Description
close #9257
Changelog:
text/applyEdit
request.Important Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.