preformance improvment when using many data_pool objects
Build Debian Packages / build (trixie, debian13) (push) Successful in 13m42s
Build Debian Packages / build (bookworm, debian12) (push) Successful in 13m56s

This commit is contained in:
2026-07-12 22:52:39 +02:00
parent a75917efd5
commit ebc2daf170
+10 -3
View File
@@ -597,22 +597,29 @@ class DamarisGUI:
# Check if we have significant listener activity
needs_full_cleanup = False
listener_count = 0
data_items = 0
if hasattr(self.monitor, 'data_pool') and self.monitor.data_pool is not None:
try:
# Count actual listeners instead of just items
# Count both listeners and data items for analysis
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
data_items = len(self.monitor.data_pool)
needs_full_cleanup = listener_count > 5 # Only full cleanup if many listeners
# Analyze the structure
flat_keys = sum(1 for key in self.monitor.data_pool.keys() if '/' not in key)
nested_keys = data_items - flat_keys
print(f"DEBUG: Data pool analysis - {data_items} total items, {flat_keys} flat, {nested_keys} nested, {listener_count} listeners")
except:
needs_full_cleanup = True
if needs_full_cleanup:
print(f"Performing full cleanup ({listener_count} listeners)...")
print(f"Performing full cleanup ({listener_count} listeners, {data_items} items)...")
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)")
print(f"Efficient cleanup ({listener_count} listeners, {data_items} items - skipping full cleanup)")
if hasattr(self.monitor, 'data_pool'):
# Just set to None - listeners will be garbage collected
self.monitor.data_pool = None