Merge branch '160-undo-performance-improvement' into '132-fix-undo-edit-last-operation-redo-handling-2'
Resolve "Undo performance improvement" See merge request slumber/multi-user!93
This commit is contained in:
@ -44,7 +44,7 @@ from . import environment
|
||||
|
||||
|
||||
DEPENDENCIES = {
|
||||
("replication", '0.1.20'),
|
||||
("replication", '0.1.22'),
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,6 +53,8 @@ from .presence import SessionStatusWidget, renderer, view3d_find
|
||||
from .timers import registry
|
||||
|
||||
background_execution_queue = Queue()
|
||||
stagging = list()
|
||||
locking = False
|
||||
deleyables = []
|
||||
stop_modal_executor = False
|
||||
|
||||
@ -79,13 +81,13 @@ def initialize_session():
|
||||
|
||||
# Step 1: Constrect nodes
|
||||
for node in session._graph.list_ordered():
|
||||
node_ref = session.get(node)
|
||||
node_ref = session.get(uuid=node)
|
||||
if node_ref.state == FETCHED:
|
||||
node_ref.resolve()
|
||||
|
||||
# Step 2: Load nodes
|
||||
for node in session._graph.list_ordered():
|
||||
node_ref = session.get(node)
|
||||
node_ref = session.get(uuid=node)
|
||||
if node_ref.state == FETCHED:
|
||||
node_ref.apply()
|
||||
|
||||
@ -118,7 +120,8 @@ def on_connection_end(reason="none"):
|
||||
|
||||
stop_modal_executor = True
|
||||
|
||||
bpy.app.handlers.depsgraph_update_post.remove(depsgraph_evaluation)
|
||||
if depsgraph_evaluation in bpy.app.handlers.depsgraph_update_post:
|
||||
bpy.app.handlers.depsgraph_update_post.remove(depsgraph_evaluation)
|
||||
|
||||
# Step 3: remove file handled
|
||||
logger = logging.getLogger()
|
||||
@ -266,7 +269,10 @@ class SessionStartOperator(bpy.types.Operator):
|
||||
# Background client updates service
|
||||
deleyables.append(timers.ClientUpdate())
|
||||
deleyables.append(timers.DynamicRightSelectTimer())
|
||||
|
||||
deleyables.append(timers.PushTimer(
|
||||
queue=stagging,
|
||||
timeout=settings.depsgraph_update_rate
|
||||
))
|
||||
session_update = timers.SessionStatusUpdate()
|
||||
session_user_sync = timers.SessionUserSync()
|
||||
session_background_executor = timers.MainThreadExecutor(
|
||||
@ -921,14 +927,11 @@ def sanitize_deps_graph(dummy):
|
||||
|
||||
"""
|
||||
if session and session.state['STATE'] == STATE_ACTIVE:
|
||||
# pass
|
||||
# session.lock_operations()
|
||||
start = utils.current_milli_time()
|
||||
for node_key in session.list():
|
||||
node = session.get(node_key)
|
||||
node.resolve(construct=False)
|
||||
logging.debug(f"Sanitize took { utils.current_milli_time()-start}ms")
|
||||
# session.unlock_operations()
|
||||
|
||||
|
||||
|
||||
@ -960,31 +963,21 @@ def depsgraph_evaluation(scene):
|
||||
# Is the object tracked ?
|
||||
if update.id.uuid:
|
||||
# Retrieve local version
|
||||
node = session.get(update.id.uuid)
|
||||
node = session.get(uuid=update.id.uuid)
|
||||
|
||||
# Check our right on this update:
|
||||
# - if its ours or ( under common and diff), launch the
|
||||
# update process
|
||||
# - if its to someone else, ignore the update (go deeper ?)
|
||||
if node and node.owner in [session.id, RP_COMMON] and node.state == UP:
|
||||
# Avoid slow geometry update
|
||||
if 'EDIT' in context.mode and \
|
||||
not settings.sync_flags.sync_during_editmode:
|
||||
break
|
||||
if node and node.owner in [session.id, RP_COMMON]:
|
||||
if node.state == UP:
|
||||
# Avoid slow geometry update
|
||||
if 'EDIT' in context.mode and \
|
||||
not settings.sync_flags.sync_during_editmode:
|
||||
break
|
||||
|
||||
# session.stash(node.uuid)
|
||||
if node.has_changed():
|
||||
try:
|
||||
session.commit(node.uuid)
|
||||
session.push(node.uuid)
|
||||
except ReferenceError:
|
||||
logging.debug(f"Reference error {node.uuid}")
|
||||
if not node.is_valid():
|
||||
session.remove(node.uuid)
|
||||
except ContextError as e:
|
||||
logging.debug(e)
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
if node.uuid not in stagging:
|
||||
stagging.append(node.uuid)
|
||||
else:
|
||||
# Distant update
|
||||
continue
|
||||
@ -992,16 +985,8 @@ def depsgraph_evaluation(scene):
|
||||
# # New items !
|
||||
# logger.error("UPDATE: ADD")
|
||||
|
||||
@persistent
|
||||
def unlock(dummy):
|
||||
if session and session.state['STATE'] == STATE_ACTIVE:
|
||||
session.unlock_operations()
|
||||
|
||||
@persistent
|
||||
def lock(dummy):
|
||||
if session and session.state['STATE'] == STATE_ACTIVE:
|
||||
session.lock_operations()
|
||||
|
||||
def clear_staging(dummy):
|
||||
stagging.clear()
|
||||
|
||||
def register():
|
||||
from bpy.utils import register_class
|
||||
@ -1009,10 +994,8 @@ def register():
|
||||
for cls in classes:
|
||||
register_class(cls)
|
||||
|
||||
bpy.app.handlers.undo_post.append(unlock)
|
||||
bpy.app.handlers.undo_pre.append(lock)
|
||||
bpy.app.handlers.redo_pre.append(unlock)
|
||||
bpy.app.handlers.redo_post.append(lock)
|
||||
bpy.app.handlers.undo_pre.append(clear_staging)
|
||||
bpy.app.handlers.redo_pre.append(clear_staging)
|
||||
|
||||
bpy.app.handlers.undo_post.append(sanitize_deps_graph)
|
||||
bpy.app.handlers.redo_post.append(sanitize_deps_graph)
|
||||
@ -1029,10 +1012,9 @@ def unregister():
|
||||
for cls in reversed(classes):
|
||||
unregister_class(cls)
|
||||
|
||||
bpy.app.handlers.undo_post.remove(unlock)
|
||||
bpy.app.handlers.undo_pre.remove(lock)
|
||||
bpy.app.handlers.redo_pre.remove(unlock)
|
||||
bpy.app.handlers.redo_post.remove(lock)
|
||||
bpy.app.handlers.undo_pre.remove(clear_staging)
|
||||
bpy.app.handlers.redo_pre.remove(clear_staging)
|
||||
|
||||
bpy.app.handlers.undo_post.remove(sanitize_deps_graph)
|
||||
bpy.app.handlers.redo_post.remove(sanitize_deps_graph)
|
||||
|
||||
|
@ -200,10 +200,10 @@ class SessionPrefs(bpy.types.AddonPreferences):
|
||||
default=1000
|
||||
)
|
||||
# Replication update settings
|
||||
depsgraph_update_rate: bpy.props.IntProperty(
|
||||
name='depsgraph update rate',
|
||||
description='Dependency graph uppdate rate (milliseconds)',
|
||||
default=1000
|
||||
depsgraph_update_rate: bpy.props.FloatProperty(
|
||||
name='depsgraph update rate (s)',
|
||||
description='Dependency graph uppdate rate (s)',
|
||||
default=1
|
||||
)
|
||||
clear_memory_filecache: bpy.props.BoolProperty(
|
||||
name="Clear memory filecache",
|
||||
|
@ -22,7 +22,7 @@ import bpy
|
||||
from replication.constants import (FETCHED, RP_COMMON, STATE_ACTIVE,
|
||||
STATE_INITIAL, STATE_LOBBY, STATE_QUITTING,
|
||||
STATE_SRV_SYNC, STATE_SYNCING, UP)
|
||||
from replication.exception import NonAuthorizedOperationError
|
||||
from replication.exception import NonAuthorizedOperationError, ContextError
|
||||
from replication.interface import session
|
||||
|
||||
from . import operators, utils
|
||||
@ -130,6 +130,31 @@ class ApplyTimer(Timer):
|
||||
if deps and node in deps:
|
||||
session.apply(n, force=True)
|
||||
|
||||
class PushTimer(Timer):
|
||||
def __init__(self, timeout=1, queue=None):
|
||||
super().__init__(timeout)
|
||||
self.id = "PushTimer"
|
||||
self.q_push = queue
|
||||
|
||||
def execute(self):
|
||||
while self.q_push:
|
||||
node = session.get(uuid= self.q_push.pop())
|
||||
|
||||
if node.has_changed():
|
||||
try:
|
||||
session.commit(node.uuid)
|
||||
session.push(node.uuid, check_data=False)
|
||||
except ReferenceError:
|
||||
logging.debug(f"Reference error {node.uuid}")
|
||||
if not node.is_valid():
|
||||
session.remove(node.uuid)
|
||||
except ContextError as e:
|
||||
logging.debug(e)
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
else:
|
||||
logging.debug("Skipping update no changes")
|
||||
|
||||
class DynamicRightSelectTimer(Timer):
|
||||
def __init__(self, timeout=.1):
|
||||
super().__init__(timeout)
|
||||
|
@ -281,6 +281,7 @@ class SESSION_PT_advanced_settings(bpy.types.Panel):
|
||||
warning = replication_section_row.box()
|
||||
warning.label(text="Don't use this with heavy meshes !", icon='ERROR')
|
||||
replication_section_row = replication_section.row()
|
||||
replication_section_row.prop(settings, "depsgraph_update_rate")
|
||||
|
||||
|
||||
cache_section = layout.row().box()
|
||||
|
Reference in New Issue
Block a user