Meshtastic-Apple/Meshtastic
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 Fix: "Retrieving nodes" significantly slower after reconnect extracted from #1424 (#1477) 2025-10-20 11:38:18 -07:00
AppIntents Fixed the message node intent (#1362) 2025-08-29 08:06:55 -07:00
Assets.xcassets 2.7.3 Working Changes (#1404) 2025-09-18 13:19:45 -07:00
Enums 2.7.4 Working Changes (#1415) 2025-10-05 17:51:18 -07:00
Export TableColumnForEach for dynamic EnvironmentMetricsLog columns (#1384) 2025-09-09 17:24:44 -07:00
Extensions Merge remote-tracking branch 'refs/remotes/origin/2.7.6' 2025-10-18 11:27:46 -07:00
Helpers Fix: "Retrieving nodes" significantly slower after reconnect extracted from #1424 (#1477) 2025-10-20 11:38:18 -07:00
Measurement little feets 2024-08-04 15:53:59 -07:00
Meshtastic.xcdatamodeld 2.7.4 Working Changes (#1415) 2025-10-05 17:51:18 -07:00
Model TableColumnForEach for dynamic EnvironmentMetricsLog columns (#1384) 2025-09-09 17:24:44 -07:00
Persistence 2.7.5 Working Changes (#1460) 2025-10-10 14:07:36 -07:00
Preview Content/Preview Assets.xcassets Rename Project to satisfy app review 2022-06-24 08:00:18 -07:00
Resources 2.7.4 Working Changes (#1415) 2025-10-05 17:51:18 -07:00
Router 2.7.4 Working Changes (#1415) 2025-10-05 17:51:18 -07:00
Tips Transports Interface to Support TCP for all Platforms and Serial on Mac (#1341) 2025-08-27 08:09:02 -07:00
Views Add back missing mesh map features 2025-10-20 11:33:58 -07:00
AppState.swift Transports Interface to Support TCP for all Platforms and Serial on Mac (#1341) 2025-08-27 08:09:02 -07:00
Info.plist 2.7.3 Working Changes (#1404) 2025-09-18 13:19:45 -07:00
Meshtastic.entitlements Transports Interface to Support TCP for all Platforms and Serial on Mac (#1341) 2025-08-27 08:09:02 -07:00
MeshtasticApp.swift Message list performance fixes into 2.7.6 (#1475) 2025-10-17 18:16:00 -07:00
MeshtasticAppDelegate.swift Transports Interface to Support TCP for all Platforms and Serial on Mac (#1341) 2025-08-27 08:09:02 -07:00
RELEASENOTES.md Rename Project to satisfy app review 2022-06-24 08:00:18 -07:00
ShowTime.swift Transports Interface to Support TCP for all Platforms and Serial on Mac (#1341) 2025-08-27 08:09:02 -07:00