Repository navigation
Plugin clients: patch the cached snapshot after the plugin's own edits - #3478
Merged
HakanSeven12 merged 1 commit intoNov 23, 2026
Merged
Conversation
An out-of-process plugin's client dropped its whole document snapshot after every entity add/update/remove, so the next read re-transferred the entire drawing; it also answered every read_record with a round trip, even for entities without a record. On a drawing of tens of megabytes a command that edits or scans entity by entity took minutes. Both clients (V2/V3 and V4) now re-read only the entities they changed with GetEntitiesBatch and patch the cached snapshot with the host's post-edit copies, mirror their own record writes and removals the way the host applies them, and answer read_record from the snapshot when the entity is in it. The cache is still dropped, and the next read fetches a fresh snapshot, whenever a patch cannot be exact: a failed or short batch read, an edited attribute (stored inside its block reference), an entity on a layer the cached table does not know, or a record of an application the cached APPID table does not know.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The out-of-process plugin clients (V2/V3
PluginHostApiand V4V4PluginHostApi) cache one document snapshot, but dropped it after every entity add/update/remove, so the nextdocument()re-transferred the whole drawing. They also answered everyread_recordwith a host round trip, even for entities that have no record. On a drawing of tens of megabytes, a plugin command that edits or scans entity by entity took minutes (one measured case: 5.5 min → about 20 s).GetEntitiesBatchalready exists for exactly this ("a plugin that writes and re-reads never re-clones the full document snapshot"); the clients now use it.Changes
ipc/snapshot_patch.rs(shared by both clients):apply_refreshed: replace/insert the host's post-edit copies of the touched entities and drop removed ones;mirror_record: apply a successfulWriteRecord/RemoveRecordto the cached entity exactly as the host does (replace or drop the app's record and its verbatim DWG EED);edit_needs_full_refresh: attribute edits (stored inside their block reference).add_entity/add_entities/update_entity/remove_entity/update_entities_transaction, re-read only the touched handles withGetEntitiesBatchand patch the cache;read_recordis answered from the snapshot when the entity is in it; record writes/removals are mirrored.Testing
GetEntitiesBatch, no secondDocumentSnapshot; records served from and mirrored into the snapshot; a new APPID and a failed batch both refetch), 4 unit tests forsnapshot_patch.cargo test -p ocs_plugin_api --features host --lib(204 passed),cargo test -p ocs_plugin_api.🤖 Generated with Claude Code