Plex Media Scanner high CPU

Hi,
For some time now with plex (sorry, its hard to pin down a specific version when this started) I’ve had very very high CPU usage by the “Plex Media Scanner” process when plex finds new content and imports it. I recall prior versions of plex where it would import each individual episode in seconds. Right now it takes several minutes, with “Plex Media Scanner” at 100% CPU, for each file its attempting to import.

I grabbed an strace call breakdown of what its doing during that time period:
`[root@charon:/.4/root21/tv]# strace -cfp 14806
Process 14806 attached with 2 threads

Process 15756 attached
Process 15806 attached
Process 15819 attached
% time seconds usecs/call calls errors syscall


98.58 6.808823 7499 908 36 futex
0.31 0.021652 1 22554 read
0.24 0.016622 173 96 poll
0.21 0.014377 0 52274 times
0.18 0.012777 0 35240 1 fcntl
0.15 0.010307 18 579 madvise
0.14 0.009458 0 22632 lseek
0.13 0.009316 0 35358 262 stat
0.01 0.001027 1 980 920 open
0.01 0.000728 1 744 write
0.01 0.000424 18 24 24 connect
0.01 0.000368 15 24 sendto
0.00 0.000243 6 43 getdents
0.00 0.000187 8 24 recvfrom
0.00 0.000072 1 107 close
0.00 0.000071 1 87 mmap
0.00 0.000047 5 10 fdatasync
0.00 0.000046 2 25 socket
0.00 0.000030 0 94 fstat
0.00 0.000021 0 43 munmap
0.00 0.000019 1 24 getpeername
0.00 0.000018 1 24 getsockname
0.00 0.000014 1 24 getsockopt
0.00 0.000013 1 16 mprotect
0.00 0.000008 0 22 openat
0.00 0.000003 1 5 rt_sigaction
0.00 0.000003 2 2 nanosleep
0.00 0.000001 1 2 sigaltstack
0.00 0.000000 0 2 access
0.00 0.000000 0 3 clone
0.00 0.000000 0 3 set_robust_list


100.00 6.906675 171973 1243 total
`

Anyone else seeing similar?

This is normal scanner operation. It reads the media file as it traverses. It then does what is needed to enter or update the media in your Plex Library.

If you would like to provide log files, I will be happy to look and see if there is another, underlying issue, which gives you the symptoms you are seeing.

Hi Chuck,
I’m sure that the operation of the scanner is normal, but it doesn’t seem normal for it to take 10+ minutes to add each new video.

Oddly, if I kill (-9) the “Plex Media Scanner” process that looks like:

/usr/lib/plexmediaserver/Plex Media Scanner --scan --refresh --section 1 --directory /.4/path/to/directory/with/video

The videos that it was scanning all get added to my library very quickly, but without preview images and without episode titles. But those titles/preview images get added shortly after.

Do you have an email I can unicast the logs to (which logs?) Not exactly private but I would prefer not to publish them.

I don’t have an email set up for such use.

I just took another look at your pathname listed.

Do you see the .4 ?? That’s a no-can-do for PMS if the directory name begins with a ..

I’ve been using a path like /.4 (or /.2 or /.1 /.# for years with plex without issues… If that’s the issue, its trivial to fix though…

There have been changes to the Scanner. It’s getting a fair amount of loving care for various reasons. I’m only highlighting the names you have because for certain types of media, music specifically, names beginning with a . (dot) are not allowed.

I have actually independently identified what the issue here was.

I had broken IPv6 at home for a few days due to a weird issue. Because of this, any IPv6 connections were timing out. Whatever service this process was reaching out to was therefore inaccessible over IPv6.

Whatever code plex was using to make this connection isn’t efficiently dealing the longer-than-normal connection time (eventually IPv4 was tried and worked) probably through the use of non-blocking IO or select instead of poll resulting in this looking like plex was busy (100% cpu) while really it was just waiting for some network I/O which was taking longer than it should.

There’s definitely something odd here in plex.

I did not see that one coming…

That was the hard way around for sure. Plex does’t use IPV6 at all because the cloud service provider doesn’t support IPV6.

Perhaps its talking to thetvdb or something?

I can try to figure out what specific service its reaching out to that’s causing it, but, I suspect the issue is more architectural.

You’re correct, it is architectural. Specifically, the cloud architecture.

When loading up TV and Movies metadata, think of the number of individual items. For a movie, it’s one item. For a tv series, it’s one item per episode. This is why a ‘hit count’ comparison looks lopsided. If you view it from purely a ‘media item’ perspective’ it makes much more sense and the 1-to-1 correlation is obvious. If you have no television episodes, you won’t see any tvdb access.

It is my experience, unless IPV6 is required, turn it off at the host level. Care must be taken to ensure IPv4 is running because access to 127.0.0.1 (the loopback adapter) is required for PMS to function at all).