backupd cleanup very slow and using tons of memory
I've been using Time Machine to backup to our Time Capsule for quite a while, but I've started noticing that backupd is using a lot of CPU and memory. When I check on it, I find it's done the backup (the Time Capsule disk is even dismounted) but the cleanup has been going on for quite a while. Looking at console and searching for backupd shows:
6/1/16 11:28:58.667 PM com.apple.backupd[19054]: Starting automatic backup
6/1/16 11:29:01.288 PM com.apple.backupd[19054]: Network destination already mounted at: /Volumes/Airport Disk
6/1/16 11:29:04.408 PM com.apple.backupd[19054]: Disk image already attached: /Volumes/Airport Disk/hummingbird.sparsebundle, DIHLDiskImageAttach returned: 35 (Resource temporarily unavailable)
6/1/16 11:29:05.668 PM com.apple.backupd[19054]: Disk image /Volumes/Airport Disk/hummingbird.sparsebundle mounted at: /Volumes/Time Machine Backups
6/1/16 11:29:07.075 PM com.apple.backupd[19054]: Backing up to /dev/disk4s2: /Volumes/Time Machine Backups/Backups.backupdb
6/1/16 11:29:36.479 PM com.apple.backupd[19054]: Will copy (469 MB) from Macintosh HD
6/1/16 11:29:36.549 PM com.apple.backupd[19054]: Found 512 files (469 MB) needing backup
6/1/16 11:29:36.616 PM com.apple.backupd[19054]: 3.29 GB required (including padding), 3.94 TB available
6/1/16 11:39:55.243 PM com.apple.backupd[19054]: Copied 856 items (469 MB) from volume Macintosh HD. Linked 10758.
6/1/16 11:40:38.954 PM com.apple.backupd[19054]: Created new backup: 2016-06-01-234037
6/1/16 11:43:30.000 PM kernel[0]: process backupd[19054] thread 5920117 caught burning CPU! It used more than 50% CPU (Actual recent usage: 59%) over 180 seconds. thread lifetime cpu usage 126.459076 seconds, (10.999206 user, 115.459870 system) ledger info: balance: 90001383867 credit: 126276955986 debit: 36275572119 limit: 90000000000 (50%) period: 180000000000 time since last refill (ns): 151181990775
6/2/16 12:07:34.000 AM kernel[0]: process backupd[19054] caught causing excessive wakeups. Observed wakeups rate (per sec): 208; Maximum permitted wakeups rate (per sec): 150; Observation period: 300 seconds; Task lifetime number of wakeups: 171334
6/2/16 1:24:10.000 AM kernel[0]: low swap: killing pid 19054 (backupd)
6/2/16 1:24:14.592 AM com.apple.backupd-helper[18183]: XPC error for connection com.apple.backupd.xpc: Connection interrupted
6/2/16 1:24:14.592 AM com.apple.backupd-helper[18183]: Not starting scheduled Time Machine backup: Failed to send message to backupd
6/2/16 1:24:17.462 AM com.apple.xpc.launchd[1]: (com.apple.backupd[19054]) Service exited due to signal: Killed: 9
Note that the backup itself finished only about 12 minutes after it started but the clean up phase lasted over another 1 1/2 hours, stopping only when the system killed backupd.
I was watching backupd from time to time. After about 20 minutes of clean up, backupd was taking 7.7 Gbytes of memory and was noticeably slowing down my Mac, which is what brought this to my attention. After about 45 minutes of clean up, the progress bar in Time Machine preferences was at 90% and not visibly moving. backupd was up to 19.92 Gbytes and growing steadily. Surprisingly, it was not slowing my mac down as much then.
Looking at subsequent backups in the log, I'm seeing the same pattern repeat.
I just used Disk Utility's First Aid to check the disk and it says my internal disk is fine.
MacBook Air, OS X El Capitan (10.11.5)