The last couple of days, my Mac (OS 10.14.6 Mojave) has had two daemon processes running hard and hot: lsd (launch service) and tccd (which apparently manages which apps have permission to access contacts and maybe other things).
Update
I have wiped my hard drive and am re-installing the OS from scratch. So answers to this question probably won't help me anymore, unless (heaven forbid) the problem reappears. However a solution might possibly help someone else.
Short summary:
lsd and tccd processes are perpetually hogging the CPU, and certain core functions that should be almost instantaneous, instead take minutes.
Details:
Here are a couple of screenshots showing CPU usage by these two processes. Note the wavy line in the graph.
Before someone marks this as a duplicate, here are some other similar questions and notes as to why they don't solve my problem:
tccd stuck and taking up lots of cpu The solution for this question was to remove XCode's access to Contacts, via System Preferences → Security & Privacy → Privacy → Contacts. However, on my machine there are no apps listed under Privacy → Contacts, neither XCode nor anything else.
This blog post about removing the TCC.db database is helpful. But I have removed that database and it didn't solve the problem.
This question about lsd and tccd only applies to Mac startup, but in my case, both processes continue running hot and heavy for hours after the machine has booted.
/usr/libexec/lsd using 100% of CPU recommends removing any .app files that are open by the lsd process. But running
pgrep -u 503 lsd | xargs lsof -pdoesn't show any .app files.What is the “lsd” process on OS X, and why is it using so much CPU power? seems similar to the problem I have, but aside from referencing the above post, it just addresses a specific error that the asker was seeing, which I'm not seeing.
mdworker gets killed 9 by mds and lsd goes high cpu seems to be very close to the problem I'm seeing. The OP there mentioned TimeMachine, and on my Mac, TimeMachine has been having a hard time successfully backing up. However, that question has no answer.
Operations that take a long time on my machine, sometimes literally minutes (sometimes they don't complete at all):
Apple menu > About this Mac: The info window can take minutes to appear.
Launcher: when I press the Option+Cmd+L shortcut, the Launcher UI appears immediately, but when I start typing, it can take minutes for any of the letters I typed to appear on the screen.
Launching apps from the Applications folder, either by double-clicking, or by selecting and pressing Cmd+O.
Links: If I click on a link in email, it can take minutes for the web page to open in the browser, even though the browser itself is responding normally in regard to clicking on links.
Restart (e.g. from the Apple menu)
The delay in launching apps by itself is a major productivity killer. I assume that problem, at least, is related to the lsd process running so hot and heavy.
I have of course rebooted (several times), but the problem keeps coming back.
I found the following in system.log in Console, showing that launchd keeps getting SIGKILLed by mds:
May 5 17:27:25 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.imfoundation.IMRemoteURLConnectionAgent): Unknown key for integer: _DirtyJetsamMemoryLimit
May 5 17:27:26 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.backupd[11719]): Service exited due to SIGABRT
May 5 17:28:04 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.mdworker.shared.0C000000-0000-0000-0000-000000000000[11748]): Service exited due to SIGKILL | sent by mds[85]
May 5 17:28:06 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.imfoundation.IMRemoteURLConnectionAgent): Unknown key for integer: _DirtyJetsamMemoryLimit
May 5 17:28:06 Lars-2015-MBP kcm[11759]: DEPRECATED USE in libdispatch client: Setting timer interval to 0 requests a 1ns timer, did you mean FOREVER (a one-shot timer)?; set a breakpoint on _dispatch_bug_deprecated to debug
May 5 17:28:12 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.backupd[11755]): Service exited due to SIGABRT
May 5 17:28:50 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.mdworker.shared.0C000000-0000-0000-0000-000000000000[11768]): Service exited due to SIGKILL | sent by mds[85]
May 5 17:28:53 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.mdworker.shared.0F000000-0000-0000-0000-000000000000[11761]): Service exited due to SIGKILL | sent by mds[85]
May 5 17:28:56 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.mdworker.shared.0F000000-0000-0000-0000-000000000000[11771]): Service exited due to SIGKILL | sent by mds[85]
May 5 17:29:08 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.imfoundation.IMRemoteURLConnectionAgent): Unknown key for integer: _DirtyJetsamMemoryLimit
May 5 17:29:09 Lars-2015-MBP kcm[11778]: DEPRECATED USE in libdispatch client: Setting timer interval to 0 requests a 1ns timer, did you mean FOREVER (a one-shot timer)?; set a breakpoint on _dispatch_bug_deprecated to debug
May 5 17:29:14 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.mdworker.shared.06000000-0000-0000-0000-000000000000): Service only ran for 4 seconds. Pushing respawn out by 6 seconds.
May 5 17:29:31 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.backupd[11769]): Service exited due to SIGABRT
May 5 17:29:52 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.mdworker.shared.02000000-0000-0000-0000-000000000000[11783]): Service exited due to SIGKILL | sent by mds[85]
May 5 17:30:02 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.mdworker.shared.04000000-0000-0000-0000-000000000000[11784]): Service exited due to SIGKILL | sent by mds[85]
May 5 17:30:03 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.mdworker.shared.06000000-0000-0000-0000-000000000000[11786]): Service exited due to SIGKILL | sent by mds[85]
May 5 17:30:07 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.mdworker.shared.0C000000-0000-0000-0000-000000000000[11797]): Service exited due to SIGKILL | sent by mds[85]
May 5 17:30:08 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.mdworker.shared.02000000-0000-0000-0000-000000000000[11799]): Service exited due to SIGKILL | sent by mds[85]
May 5 17:30:08 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.mdworker.shared.10000000-0000-0000-0000-000000000000[11798]): Service exited due to SIGKILL | sent by mds[85]
May 5 17:30:16 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.mdworker.shared.0F000000-0000-0000-0000-000000000000[11802]): Service exited due to SIGKILL | sent by mds[85]
May 5 17:30:27 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.imfoundation.IMRemoteURLConnectionAgent): Unknown key for integer: _DirtyJetsamMemoryLimit
May 5 17:30:28 Lars-2015-MBP kcm[11812]: DEPRECATED USE in libdispatch client: Setting timer interval to 0 requests a 1ns timer, did you mean FOREVER (a one-shot timer)?; set a breakpoint on _dispatch_bug_deprecated to debug
May 5 17:30:36 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.backupd[11804]): Service exited due to SIGABRT
May 5 17:31:14 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.mdworker.shared.0C000000-0000-0000-0000-000000000000[11819]): Service exited due to SIGKILL | sent by mds[85]
May 5 17:31:20 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.imfoundation.IMRemoteURLConnectionAgent): Unknown key for integer: _DirtyJetsamMemoryLimit
May 5 17:31:22 Lars-2015-MBP kcm[11828]: DEPRECATED USE in libdispatch client: Setting timer interval to 0 requests a 1ns timer, did you mean FOREVER (a one-shot timer)?; set a breakpoint on _dispatch_bug_deprecated to debug
May 5 17:31:32 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.backupd[11824]): Service exited due to SIGABRT
May 5 17:31:47 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.imfoundation.IMRemoteURLConnectionAgent): Unknown key for integer: _DirtyJetsamMemoryLimit
May 5 17:32:19 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.mdworker.shared.0C000000-0000-0000-0000-000000000000[11839]): Service exited due to SIGKILL | sent by mds[85]
May 5 17:32:26 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.mdworker.shared.0F000000-0000-0000-0000-000000000000[11843]): Service exited due to SIGKILL | sent by mds[85]
May 5 17:32:31 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.imfoundation.IMRemoteURLConnectionAgent): Unknown key for integer: _DirtyJetsamMemoryLimit
May 5 17:32:36 Lars-2015-MBP kcm[11853]: DEPRECATED USE in libdispatch client: Setting timer interval to 0 requests a 1ns timer, did you mean FOREVER (a one-shot timer)?; set a breakpoint on _dispatch_bug_deprecated to debug
May 5 17:32:47 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.backupd[11845]): Service exited due to SIGABRT
May 5 17:33:23 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.mdworker.shared.0C000000-0000-0000-0000-000000000000[11859]): Service exited due to SIGKILL | sent by mds[85]
May 5 17:33:37 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.imfoundation.IMRemoteURLConnectionAgent): Unknown key for integer: _DirtyJetsamMemoryLimit
May 5 17:33:40 Lars-2015-MBP kcm[11869]: DEPRECATED USE in libdispatch client: Setting timer interval to 0 requests a 1ns timer, did you mean FOREVER (a one-shot timer)?; set a breakpoint on _dispatch_bug_deprecated to debug
May 5 17:33:50 Lars-2015-MBP com.apple.xpc.launchd[1] (com.apple.backupd[11864]): Service exited due to SIGABRT
And I found diagnostic files saying that lsd and tccd had been exceeding limits:
lsd_2021-05-05-120341_Lars-2015-MBP.cpu_resource.diagsays "90 seconds cpu time over 102 seconds (88% cpu average), exceeding limit of 50% cpu over 180 seconds". In addition to "Powerstats for: lsd" it also lists "Powerstats for: tccd".tccd_2021-05-05-152931_Lars-2015-MBP.wakeups_resource.diagsays "45009 wakeups over the last 297 seconds (151 wakeups per second average), exceeding limit of 150 wakeups per second over 300 seconds" and also has lots to say about LaunchServices.
Of course there's much more in these diagnostic files, but I don't really know how to identify the cause of the problem, out of the flood of data. Click on the links above to see the files on pastebin.
I also found the following crash report for backupd, which had been crashing very frequently:
Process terminated due to uncaught exception: IllegalArgumentException: object cannot be nil
The above message is from (human) memory. Now that I've wiped the hard drive and am reinstalling the OS, I can't check the exact text at the moment.

