Meshtastic-Apple/Meshtastic/Helpers
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
..
Mqtt update mqtt port parsing 2025-07-21 12:00:55 -07:00
BluetoothManager.swift Rename Project to satisfy app review 2022-06-24 08:00:18 -07:00
CommonRegex.swift Run swiftlint --fix over the project 2024-07-09 20:03:40 -05:00
ContactURLHandler.swift Transports Interface to Support TCP for all Platforms and Serial on Mac (#1341) 2025-08-27 08:09:02 -07:00
EmojiOnlyTextField.swift Swiftlint fixes 2024-06-02 18:32:14 -07:00
GeoJSONOverlayConfig.swift Update Meshtastic/Helpers/GeoJSONOverlayConfig.swift 2025-07-28 11:30:03 -07:00
GeoJSONOverlayManager.swift spaces -> tabs 2025-07-23 20:58:46 +00:00
KeychainHelper.swift iCloud Private key backup initial commit 2025-06-18 01:00:27 -07:00
LocalNotificationManager.swift 2.7.5 Working Changes (#1460) 2025-10-10 14:07:36 -07:00
LocationsHandler.swift 2.7.4 Working Changes (#1415) 2025-10-05 17:51:18 -07:00
Logger.swift Extract the generated protobufs into its own Swift package 2024-06-28 11:11:01 -05:00
MapDataManager.swift Add german translations (#1383) 2025-09-11 18:49:47 -07:00
MeshPackets.swift Fix: "Retrieving nodes" significantly slower after reconnect extracted from #1424 (#1477) 2025-10-20 11:38:18 -07:00
Preferences.swift Rename Project to satisfy app review 2022-06-24 08:00:18 -07:00