-
Notifications
You must be signed in to change notification settings - Fork 326
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
Remove IdMap from source file. #9257
Comments
The Truffle instrumentation is built around SourceSectionFilter, not UUIDs. The filter uses ranges (offset, line, column) and tags. It would be great if we adhered more closely to the capabilities offered by Truffle when eliminating the IdMap usage.
Then the AST is hosted in the same process as the engine and its instrumentation. Assuming y.js is efficient in synchronizing AST modifications, we don't need UUIDs to keep element identities. The AST elements themselves represent identity. Visualizations shall become part of the AST - attaching/removing them modifies some attribute of clearly identified AST element. When there is an AST change that modifies the source code we need to traverse the AST and recompute ranges (offset, line, column) of elements that require instrumentation. A change in the source code always comes with new ranges. All of that is done inside of a single process without any need for network communication via a special protocol. Opportunities with visualizations: Y.js system offers concept of subdocuments - lazily loaded entities used for on demand synchronization. We could use them for distributing visualizations across the peers. IDEs would annotate an AST element as eligible for obtaining visualization. Engine would compute the visualization and attach it as a subdocument. IDEs interested in that visualization would load it and observe its changes. Longer term future vision: with the AST being in the same process as Truffle we should make a connection between the AST elements and Truffle nodes and avoid reparsing the whole |
I have rephrased the strategic vision in a separate document. An essential part of it still remains the sharing of ASTs among peers via y.js server. |
#10182 will add an optional IdMap parameter in the I propose to simplify the serialized IdMap elements format from the current [[{"index":{"value":0},"size":{"value":4}},"bfae92f7-07d0-4886-b37b-a26e17ee943f"],...] to an array of 3 elements: index, size and uuid [[0,4,"bfae92f7-07d0-4886-b37b-a26e17ee943f"],...] |
I'm ok, but perhaps we should support reading both formats for some time. |
Yes, being able to read previous node positions in new IDE is essential. |
I'm not going to change the parser. I was talking about the JSON-RPC |
#10283 adds an optional interface TextApplyEditParameters {
/** The file edit. */
edit: FileEdit;
/**
* A flag indicating whether we should re-execute the program after applying
* the edit. Default value is `true`, indicating the program should be
* re-executed.
*/
execute?: boolean;
/**
* An identifiers map associated with this file as an array of
* index, length, uuid triples. The old id map format that was used in the
* source file is also supported.
*/
idMap?: [number, number, UUID][];
} @farmaazon the next step could be to keep in the file only the IDs that are used in the second metadata line (with node positions, etc.) and send the rest of the IDs with the |
Looks good, I'm ready to help with ydoc-server code if needed. |
Dmitry Bushev reports a new STANDUP for today (2024-06-24): Progress: Started working on storing the reduced IdMap in the file. Implemented the IdMap diff. Implemented sending IdMap in the applyEdit request. It should be finished by 2024-06-29. Next Day: Next day I will be working on the #9257 task. Continue working on the task |
Dmitry Bushev reports a new STANDUP for today (2024-06-25): Progress: Playing with different usage cases. Debugged and fixed the issue with the metadata recovery. Fixed the issue with the broken IdMap between the project restarts. Undrafted the PR It should be finished by 2024-06-29. Next Day: Next day I will be working on the #9257 task. Continue working on the task |
The id-map grows with the code rapidly, and even reducing its size won't help much; still, the id-map tends to take 100x more space than the code it describes. But perhaps we don't need to store them in file at all.
Main idea
Instead of storing id-map in source file, we could exchange it using Language Server API.
The id-map purpose is to make an identification of particular AST nodes, what in turn is needed to:
The second point do not require AST IDs persistence, while the first point may be handled by storing direct spans instead of IDs in the source file.
Further ideas and optimizations
Gui Tasks
Engine Tasks
The text was updated successfully, but these errors were encountered: