marker: batch topology dumps in bulk fan-out (per-def on 500+ links was ~1 minute)

Every per-link marker operation (start_marker / stop_marker / update_marker) called Project.dump() -- a full topology serialization + file write. A definition fan-out over 500 links therefore wrote the whole topology 500+ times (each blocking the event loop), which dominated the observed ~1 minute; the NIO round-trips themselves were negligible.

Add a dump: bool = True parameter to the three per-link operations and inherit_marker (matching the existing dump param on Link.add_node). The bulk paths -- definition create fan-out, definition-update sync and re-fan-out, definition-delete cleanup, pause/resume, new-link inheritance -- pass dump=False and their caller dumps once after. apply_defs_to_new_link suppresses per-def dumps too: link create / project open dump once after, so opening a 500-link project with N definitions no longer does 500xN topology writes.
This commit is contained in:
YueGuobin committed 2026-08-08 00:03:30 +08:00
1 parent 078cf92aef
commit ad8bac8328
3 files changed
+41 -17

No files matched your search

+2 -1
View File
@@ -114,7 +114,7 @@ class Link:
"""
return self._markers
async def inherit_marker(self, def_name, marker_def):
async def inherit_marker(self, def_name, marker_def, dump=True):
"""
Apply a project-level marker definition to this link.
@@ -147,6 +147,7 @@ class Link:
highlight_duration=marker_def.get("highlight_duration"),
enabled=not marker_def.get("paused", False),
inherited_from=def_name,
dump=dump,
)
def _persist_markers(self):