Meshtastic-Apple/Meshtastic/Accessory
Garth Vander Houwen 16e56e7f07
Fix: "Retrieving nodes" significantly slower after reconnect extracted from #1424 (#1477)
* Fix: "Retrieving nodes" significantly slower after reconnect (#1424)

The node database retrieval was calling context.save() for every single
NodeInfo packet received (250 saves for 250 nodes). This caused severe
performance degradation on reconnect when CoreData had accumulated state.

Root Cause:
- nodeInfoPacket() called context.save() immediately for each node
- With 250 nodes, this meant 250 individual CoreData save operations
- On first connection, CoreData is fresh and fast
- On reconnect, CoreData has accumulated change tracking, undo management,
  and memory pressure, making each save progressively slower
- This resulted in 10+ second retrieval times vs 1-2 seconds initially

Solution:
- Added deferSave parameter to nodeInfoPacket() function
- During database retrieval (.retrievingDatabase state), defer all saves
- Perform a single batch save when database retrieval completes
  (when NONCE_ONLY_DB configCompleteID is received)
- This reduces 250 saves to 1 save

Performance Impact:
- Eliminates N individual saves during node database sync
- Reduces database retrieval time back to 1-2 seconds on reconnect
- Matches first-connection performance consistently

Fixes #1424

* Revert *MessageListUnified files

---------

Co-authored-by: Martin Bogomolni <martinbogo@gmail.com>
Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
2025-10-20 11:38:18 -07:00
..
Accessory Manager Fix: "Retrieving nodes" significantly slower after reconnect extracted from #1424 (#1477) 2025-10-20 11:38:18 -07:00
Helpers 2.7.4 Working Changes (#1415) 2025-10-05 17:51:18 -07:00
Protocols Message list performance fixes into 2.7.6 (#1475) 2025-10-17 18:16:00 -07:00
Transports Message list performance fixes into 2.7.6 (#1475) 2025-10-17 18:16:00 -07:00