MacOS – Slow pbpaste / pbcopy

macos

Laptop: Late 2013, i7, 500G SSD, 16G of ram

El Capitan 10.11.1

When I try and pbcopy and pbpaste on the command line they are running awfully slow. This ties into an emacs issue I'm having as well but since pbcopy/paste is the root of it I'm asking here….

Here is some example output:

~❯ time echo 'test' | pbcopy
echo 'test'  0.00s user 0.00s system 24% cpu 0.003 total
pbcopy  0.01s user 0.01s system 1% cpu 0.830 total
~❯ time echo 'test' | pbcopy
echo 'test'  0.00s user 0.00s system 38% cpu 0.002 total
pbcopy  0.01s user 0.01s system 1% cpu 0.847 total
~❯ time echo 'test' | pbcopy
echo 'test'  0.00s user 0.00s system 40% cpu 0.001 total
pbcopy  0.01s user 0.01s system 0% cpu 1.708 total
~❯ time pbpaste
test
pbpaste  0.01s user 0.01s system 1% cpu 0.860 total
~❯ time pbpaste
test
pbpaste  0.01s user 0.01s system 1% cpu 0.843 total
~❯ time pbpaste
test
pbpaste  0.01s user 0.01s system 1% cpu 0.853 total

If I watch Activity Monitor and set sampling to 1 second – I can see notifyd jump to 100% CPU usage everytime I run pbcopy.

If I kill notifyd pbcopy/paste works blazingly fast:

time echo 'test' | pbcopy
echo 'test'  0.00s user 0.00s system 38% cpu 0.002 total
pbcopy  0.01s user 0.01s system 80% cpu 0.015 total

El Capitan bug? Something else? Thanks in advance for any responses.

Best Answer

Consider reporting this directly to Apple via bug reporter as it is unlikely anyone here will be able to help.

Delays of around point zero one less than one second are probably acceptable to Apple's engineers. 100% CPU is also acceptable; useful work is being done for the user when copying and pasting.

The pasteboard is not designed as a performance focused transport mechanism for processes and scripts.

Pasteboard operations can result in a cascade of notifications to processes. This is likely what you are detecting as notifyd is responsible for system wide notification delivery. This behaviour is normal.