Public Access
preformance improvment when using many data_pool objects
This commit is contained in:
@@ -588,11 +588,36 @@ class DamarisGUI:
|
||||
self.toolbar_pause_button.set_sensitive( True )
|
||||
self.toolbar_pause_button.set_active( False )
|
||||
|
||||
# delete old data
|
||||
# delete old data - use efficient cleanup
|
||||
data_cleanup_start = time.time()
|
||||
self.data = None
|
||||
self.monitor.observe_data_pool( self.data )
|
||||
print(f"DEBUG: Data cleanup took {time.time() - data_cleanup_start:.3f}s")
|
||||
|
||||
# Modern listener management - only clean up listeners when truly needed
|
||||
if hasattr(self, 'monitor') and self.monitor is not None:
|
||||
# Check if we have significant listener activity
|
||||
needs_full_cleanup = False
|
||||
listener_count = 0
|
||||
|
||||
if hasattr(self.monitor, 'data_pool') and self.monitor.data_pool is not None:
|
||||
try:
|
||||
# Count actual listeners instead of just items
|
||||
with self.monitor.data_pool.__dictlock:
|
||||
listener_count = len(self.monitor.data_pool.__registered_listeners) if hasattr(self.monitor.data_pool, '__registered_listeners') else 0
|
||||
needs_full_cleanup = listener_count > 5 # Only full cleanup if many listeners
|
||||
except:
|
||||
needs_full_cleanup = True
|
||||
|
||||
if needs_full_cleanup:
|
||||
print(f"Performing full cleanup ({listener_count} listeners)...")
|
||||
self.monitor.observe_data_pool( self.data )
|
||||
else:
|
||||
# Efficient cleanup: just reset references without full listener cleanup
|
||||
print(f"Efficient cleanup ({listener_count} listeners - skipping full cleanup)")
|
||||
if hasattr(self.monitor, 'data_pool'):
|
||||
# Just set to None - listeners will be garbage collected
|
||||
self.monitor.data_pool = None
|
||||
|
||||
print(f"DEBUG: Efficient data cleanup took {time.time() - data_cleanup_start:.3f}s")
|
||||
|
||||
# set the text mark for hdf logging
|
||||
if self.log.textbuffer.get_mark( "lastdumped" ) is None:
|
||||
|
||||
Reference in New Issue
Block a user