Hi flipflips, I followed Jeremy's instructions, and now the issue is solved. So let me explain how to do this in more detail.
But before taking off: beware that tinkering with the Mac system using the Terminal is risky business. I had a long conversation with Apple Care, who took me through a lot of steps, and they in general advise to NOT use Terminal.
So, make sure to have a backup of all your files, and check the contents of the log-files to check that your issue is caused by exactly the same issue that Jeremy reported. That is how I did it, and it worked for me.
And if your system gets unstable, you can always go back to factory defaults, and start over from there :)
Now, first we will check the log files.
To do this, start Spotlight (the looking-glass symbol in the upper righthand corner of the screen) and type:
/var/log/asl
This brings up a Finder window with the folder with the log-files.
Those log-files have a name like:
2020.06.30.xxx.asl
You can open the log-file with the program Console (that is the default program, or you can use Open with...)
Check this log-file for lines as:
libcoreservices: __makeDirectory: 405: mkdir: path=/var/folders/zz/[randomized name]/0/ mode=0755: Operation not permitted.
The [randomize name] part is a long string like zyxvpxvq6csfxvn_n00000y800007k
This string is important: it is the name of a system subdirectory that is used by the nsurlsessiond process. Nsurlsessiond tries to write to this directory, but gets no permission, and repeats and repeats and repeats and repeats. That's why nsurlsessiond stays in the top of your list of processes, eating up to 50-60% of your CPU capacity, draining your battery, and heating your MacBook.
So check if you see these lines in your log file, to make sure your issue is the same.
To solve the issue you have to do 2 things:
- Kill the trustd process
- Delete the blocked directory, so that the OS can create a new one.
These things are done using the Terminal. You can find this program in the Launchpad, or find it using Spotlight.
First, find the name of the subdirectory (the string mentioned above). Copy it from the log-file, or find it using the Terminal.
Start the Terminal program. The Terminal window opens. After the prompt, type:
ls -la /var/folders/zz | grep nsurlsessiond
You will get an output like:
drwxr-xr-x@ 5 _nsurlsessiond _nsurlsessiond 160 9 jun 13:45 zyxvpxvq6csfxvn_n00000y800007k
The part that I made bold is the name of the subdirectory we need to delete, so copy this to your Clipboard.
Now, take a look again at the Activity monitor, and look for the trustd process, that is one of the top 3 or 4 processes in the list. It has a unique process id, the PID number (for example 219).
In Terminal, kill the trustd process, by typing:
sudo kill -9 [trustd PID]
So if the PID is 219, you type:
sudo kill -9 219
After killing this process, you will see the CPU usage drop immediately.
Now we delete the subdirectory. Again in Terminal, type
sudo rm -fr /var/folders/zz/[randomized name]
Again, replace [randomized name] with the string you copied before.
Congratulations, you are done!
Keep following your system performance for several days in the Activity Monitor.
Success!