INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2   Go Down

Author Topic: Best Database Performance  (Read 3014 times)

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Best Database Performance
« on: November 06, 2020, 07:37:57 am »

I am running MC on a quad core Win10 system. It plays music, pictures and videos without any problem.
However, database performance is sometimes poor. There are around 500,000 titles in the database. Opening the artist view in theater mode sometimes takes 3 seconds. Another time it takes> 20 seconds. Sometimes it opens up within a few seconds but gets stuck as you scroll through the covers. Then the HDD LED lights up continuously and Task Manager shows 100% disk activity for MediaCenter. What could be the reason for this high activity?

Then there is the unpredictable behavior of Windows. Sometimes processes like 'WAAS health', 'Telemetry', 'Antimalware executable' and 'Module Installer' need a multiple of the CPU time that MC receives.

I am now wondering whether switching to Linux will bring any improvement. I suspect that such background processes run less aggressively here. Can someone make comparative information regarding the DB performance and operation?

I know that different settings could improve something under Win10. But if I imagine that everything will be overwritten again with the next Win10 update, I prefer to invest the time in Linux.
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 71439
  • Where did I put my teeth?
Re: Best Database Performance
« Reply #1 on: November 06, 2020, 07:48:52 am »

Make sure you have Windows Defender configured.  There is a thread here.

Is it a local disk?  Or network or USB?

You can turn off Audio Analysis.  Build the thumbnails in settings > View.

Take a look at Reporter under Drives and Devices.
Logged

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Best Database Performance
« Reply #2 on: November 06, 2020, 08:49:01 am »

Hi Jim
Thanks for the quick reply. I know about the issues with defender. I ask myself if it is worth to deal with Win10. Setting up Linux would be no problem. I just want to know which OS delivers the best MC Database performance on an ASUS PUNDIT from 2017.

Actually all music is stored on a NAS. Playback starts immediately after click. Only DB Browsing is sometimes interrupted for 5 to 15 seconds.
DB is stored on the local SSD. All thumbnails are generated.

 
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 71439
  • Where did I put my teeth?
Re: Best Database Performance
« Reply #3 on: November 06, 2020, 10:22:24 am »

Did you import the files from the NAS into MC? 

Or are you using the NAS's DLNA server.  Not recommended.
Logged

Gedeon

  • World Citizen
  • ***
  • Posts: 105
Re: Best Database Performance
« Reply #4 on: November 06, 2020, 12:52:36 pm »

Do you run the system/JRiver over SSD or HDD ?

SSD are way better for that purpose.
Logged

jherbert

  • World Citizen
  • ***
  • Posts: 120
Re: Best Database Performance
« Reply #5 on: November 06, 2020, 01:09:58 pm »

I would like to second that. I run jriver on a really fast machine (AMD 3700x, 64 GB RAM, database on NVMe 4 drive...

Switching views takes quite a while, entering search terms is a pain and there are several seconds lag before an entry is displayed. Once displayed it takes years till the search window is ready for editing / appending.

Not much change from the previous Intel-based system (i7, 32 GB, NVMe 3 drive...)

Seems mediacenter maxes out well below 500.000 tracks. But then, what do I know.

I do not get that windows defender stuff. Why should a well designed piece of software force me to turn down my defenses?

Sorry, not meant to be rude. But mediacenter is such a beautiful and useful piece of software that I hate to see that sort of performance.
Logged

Awesome Donkey

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 7395
  • The color of Spring...
Re: Best Database Performance
« Reply #6 on: November 06, 2020, 02:12:23 pm »

I do not get that windows defender stuff. Why should a well designed piece of software force me to turn down my defenses?

You're not, you're setting exclusions in Windows Defender which makes it where it won't scan Media Center's executables and %APPDATA% library files location, so it doesn't interfere with Media Center's operation. Adding those exclusions doesn't compromise Windows Defender itself (nor are you changing any of its settings, so it still works as-is, but it won't scan Media Center's files, which can cause performance issues) or the overall security of your Windows install.

Antivirus and antimalware applications, including Windows Defender, do have an impact on Media Center's performance. In Defender's case it actively scanning any files Media Center has loaded (and any files in your library) which because it does real-time virus scanning, can impact performance if you have a lot of files. If you know all your media files are clean (and Media Center's files are clean - you can verify the digital signature for nearly all of Media Center's executable and DLL files) adding exclusions won't hurt security, but it'll likely increase performance. If you've noticed that when trying to start Media Center it takes 10+ seconds for Media Center to appear, that's a good indication that Defender (or any other antivirus application) is actively scanning/submitting samples Media Center's executable(s) and/or DLL files, which causes it to open slowly. If this happens on your system open Task Manager, go to the Details tab and look at how much resources Defender's processes are using while waiting, then see if the resource usage drops once Media Center actually starts. That's a good indicator that Defender (or your antivirus app) is causing issues.

I personally have Windows Defender's exclusions set to Media Center's install directory, Media Center's %APPDATA% folder and my main drives (and locations) that contain my media files that are imported into Media Center and I don't have any performance issues in Media Center with nearly 120,000 FLAC files imported.
Logged
I don't work for JRiver... I help keep the forums safe from Viagra and other sources of sketchy pharmaceuticals.

Windows 11 2023 Update (23H2) 64-bit + Ubuntu 24.04 LTS Noble Numbat 64-bit | Windows 11 2023 Update (23H2) 64-bit (Intel N305 Fanless NUC 16GB RAM/256GB NVMe SSD)
JRiver Media Center 32 (Windows + Linux) | iFi ZEN DAC 3 | Edifier R2000DB Bookshelf Speakers | Audio-Technica ATH-M50x Headphones

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Best Database Performance
« Reply #7 on: November 07, 2020, 02:06:31 am »

Make sure you have your Library (not the Media Files themselves, that doesn't matter much, but MC's database itself) on a fast disk, preferably a SSD:
https://wiki.jriver.com/index.php/Troubleshooting_Network_and_Slow_Storage

If you have your Media Files on a NAS and your views are slow to open, that's thing one. Make sure you didn't decide to put MC's Library (database) on the NAS too. That doesn't help anything, and just makes it run slow.

If you already have that right, other things (all included in that article linked above) that might help include:

* I completely concur with the comments on anti-virus discussed above. It, unfortunately, isn't up to MC (or JRiver) to just be "well behaved" in order to get along with your AV application. AV interferes with all application performance. The AV vendors just tune them to work well with popular applications. They devote hundreds of programmer hours making sure it doesn't mess up Excel too bad (and it still does, trust me), but I can't imagine they care too much about JRiver Media Center 27. And, then, there are tons of AV vendors all working independently (and some are much, much better behaved than others).

* Options > Tree & View > Advanced > Display missing file image in lists. Turn this off if you have your media on a slow disk (or one that sleeps) and your Views are slow to open.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

Manfred

  • Citizen of the Universe
  • *****
  • Posts: 1023
Re: Best Database Performance
« Reply #8 on: November 07, 2020, 06:15:11 am »

I have a much smaller lib: 42942 files, library size: 348 MB; 937 MB in thumbnails.

I don't have a NAS anymore, I have now MC client server architecture: MacBook Pro (has only a subset of my lib and  I use it only if I am traveling for my Job), Workstation Client (Home Office), Server (in a spearate room), Renderer Client in the living room

MC Reporter reports the following "Drive Info" for reading a 256 MB file for my 3 different SSD's excluding the MacBook

make/read   0.527/0.509 sec | 500 GB Samsung 840 EVO SATA           | Workstation Client
make/read   1.097/0.488 sec |   64 GB TS64GMTG400 SATA                | Server
make/read   0.899/0.517 sec | 128 GB IntelSSDPEKW128G7 pcie x4    | Media Renderer Client
Logged
WS (AMD Ryzen 7 5700G, 32 GB DDR4-3200, 2x2 TB SDD, LG 34UC98-W)-USB|ADI-2 DAC FS|Canton AM5 - File Server (i3-3.9 GHz, 16GB ECC DDR4-2400, 46 TB disk space) - Media Renderer (i3-3.8 GHz, 8GB DDR4-2133, GTX 960)-USB|Devialet D220 Pro|Audeze LCD 2|B&W 804S|LG 4K OLED )

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Best Database Performance
« Reply #9 on: November 07, 2020, 07:46:42 am »

Thanks for all the hints. As you see in my 2nd post, my DB is stored on my local SSD. Also Win10 and MC is running from this SSD.
Files are stored on a NAS. They are accessed through SMB. A drive letter is assigned to the share.

Read/Write performance from/to NAS is fine. Clicking on a track or image opens that medie file without noticeable delay.
Database performance is poor. Opening a view with several hundred artists may take 20 seconds. The performace of the NAS should not influence that, because all DB data including the thumbnails are on my SSD.


Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Best Database Performance
« Reply #10 on: November 07, 2020, 10:38:18 am »

Read/Write performance from/to NAS is fine. Clicking on a track or image opens that medie file without noticeable delay.
Database performance is poor. Opening a view with several hundred artists may take 20 seconds. The performace of the NAS should not influence that, because all DB data including the thumbnails are on my SSD.

Not if you leave this enabled (and it is by default):
* Options > Tree & View > Advanced > Display missing file image in lists. Turn this off if you have your media on a slow disk (or one that sleeps) and your Views are slow to open.

Then it has to check on disk for the existence on disk of any file visible in the view. If scrolling performance is sometimes bad as well, this is a very likely candidate with what you explained.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Best Database Performance
« Reply #11 on: November 07, 2020, 12:23:17 pm »

Hi Glynor
This option is unchecked.
After MC is restarted, the first time opening Artist in Theater view the task manager shows the following:
During 120 seconds MC reads from SSD with approx. 35MB/s (80% usage)
After the first 40 seconds, the album covers were shown. But when fast scrolling down, an empty screen is shown.

When I close MC during this time, the drive activities keep on going. Mediaserver is off!

Since I do not notice relevant network activities, it must be related to the database and sorting.
Logged

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Best Database Performance
« Reply #12 on: November 07, 2020, 12:54:27 pm »

Update:
I repeated the same procedure once again. Now I do not see SSD load and the Artist view is displayed within 3 seconds.
But when scrolling down, I come to a blank screen and disk load goes again to 80% for a long time. During this, also the "Exit Theater View"  will be drawn with empty frames. No text.

Could this be a problem caused by too less RAM ? There are just 4GB. But Task Manager reports that no more than 50% is used. 
Logged

Jamil

  • Galactic Citizen
  • ****
  • Posts: 395
Re: Best Database Performance
« Reply #13 on: November 07, 2020, 01:09:21 pm »

I am now wondering whether switching to Linux will bring any improvement. I suspect that such background processes run less aggressively here. Can someone make comparative information regarding the DB performance and operation?

I recently switched from Windows 10 Professional to Ubuntu Linux 20.04.  I use the latest available Linux version and can share some experience with this, if you are still considering switching to Linux.

The latest Linux version of MC now looks practically identical to the Windows version.  There are some differences though.  One is the application speed.  The Linux version is actually a little slower than the Windows version as far as the UI screen is concerned.  Screen draws are a little slower in some instances.  There are also some other differences between the two.  These products are works in progress and continually undergoing improvement most of the time, but the Linux version has differences that the Windows version does not.

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Best Database Performance
« Reply #14 on: November 07, 2020, 01:38:43 pm »

After MC is restarted, the first time opening Artist in Theater view the task manager shows the following:
During 120 seconds MC reads from SSD with approx. 35MB/s (80% usage)
After the first 40 seconds, the album covers were shown. But when fast scrolling down, an empty screen is shown.

Just FYI, something is definitely "wrong". None of this is typical, and I don't see similar behavior on any of my Windows 10 machines.

It really sounds like it could be AV. You may have already said this above (I didn't go back and read again) but to confirm: Have you tried, just as a test, completely disabling your AV (uninstalling it if it is a 3rd party one, because the "disablers" don't always disable everything) and trying to replicate the behavior?

One other thing you can try:

1. Make a Library Backup.
2. Close MC entirely.
3. Delete the current Library folder on disk.
4. Reopen MC and have it restore the Library from the backup you made in Step 1.

If there is something corrupt in the Library (or the File Sort Cache) this will fix that.

I'd also do a chkdsk scan on the drive where the Library is stored.

(Again, with all of the above, I'm NOT talking about where the media itself is stored, but where MC stores its database. This is in your AppData folder by default, but you can make different locations.)
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 71439
  • Where did I put my teeth?
Re: Best Database Performance
« Reply #15 on: November 07, 2020, 06:23:30 pm »

I repeated the same procedure once again. Now I do not see SSD load and the Artist view is displayed within 3 seconds.
But when scrolling down, I come to a blank screen and disk load goes again to 80% for a long time. During this, also the "Exit Theater View"  will be drawn with empty frames. No text
That just sounds like disk I/O isn't keeping up.  The NAS will always be slower, but antivirus can also do that.
Logged

struct

  • Galactic Citizen
  • ****
  • Posts: 380
Re: Best Database Performance
« Reply #16 on: November 08, 2020, 12:08:52 am »

Is the coverart and thumbnails also on the SSD?
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Best Database Performance
« Reply #17 on: November 08, 2020, 01:43:39 am »

Could this be a problem caused by too less RAM ? There are just 4GB. But Task Manager reports that no more than 50% is used.

This. I run only 8GB of memory of my workstation at the moment, and that works fine. But just MC plus Chrome is using 4.3GB. Any PC running Windows 10 Professional should really have more than 4GB of memory. I used to run 6GB on the Workstation, and that was also fine, but I saw quite a bit of memory paging.

If I was building a new PC, for any purpose, I would not use less than 16GB, and would probably go for 32GB now. My 2013 HTPC has 16GB. As a minimum though, 8GB. Can you upgrade the memory in that PC?

You say only 50% of memory is in use. What do the memory stats in Task Manager look like? Attached image shows my Workstation with 8GB of physical memory.

During 120 seconds MC reads from SSD with approx. 35MB/s (80% usage)

If I understand what you are saying there, that is a very, very slow SSD. It sounds like the top speed is about 44MB/s.

My 2012 Intel 520 SSD runs at 550/520 MB/s Read/Write. If the above is correct, something is seriously wrong. It could just be the 4GB of memory and a lot of memory paging, which would be made a lot worse if the drive was nearly full. All Windows system drives should have at least 10% of its capacity in free space. What model of SSD do you have? What capacity? How much free space do you have on the SSD?

Manfred showed his "Drive Info" above. This is new information found under "Help > System Info > Drive Info". What does MC report about the SSD in your PC?
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Best Database Performance
« Reply #18 on: November 08, 2020, 03:34:46 am »

Thank you for the valuable information.
The database and the NAS MIGHT be the cause. However, I use a copy of the same DB on other computers and access the same NAS in the same network without any problems.

The more I deal with it, the more I see the RAM as a possible cause. My thumbnails take up 9.4GB. With 16GB of RAM, the OS can hold these files in memory. However, where Win reports only 2 GB of free space, this is not possible.
If MC accesses elements from the thumbnails in random order when opening a view, then the reading speed / access time can become a problem. Even on an SSD.

What do you think about that?
Logged

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Best Database Performance
« Reply #19 on: November 08, 2020, 03:39:57 am »

I recently switched from Windows 10 Professional to Ubuntu Linux 20.04.  I use the latest available Linux version and can share some experience with this, if you are still considering switching to Linux.

The latest Linux version of MC now looks practically identical to the Windows version.  There are some differences though.  One is the application speed.  The Linux version is actually a little slower than the Windows version as far as the UI screen is concerned.  Screen draws are a little slower in some instances.  There are also some other differences between the two.  These products are works in progress and continually undergoing improvement most of the time, but the Linux version has differences that the Windows version does not.

Jamil,
Do I understand correctly ? The Linux version does not promise any improvements?
Yesterday I set up MC on Debian and tested it. I share your assessment of the responsiveness of the GUI.
After MC stopped during the import after 10,000 tracks, I uninstalled everything again. I can wait with Windows too ;-)
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Best Database Performance
« Reply #20 on: November 08, 2020, 03:25:33 pm »

What do you think about that?

That could certainly be a contributor. The Thumbnails database is created and used to improve image access performance, but with som many files, such a large Thumbnails database, and so little memory in the PC, I have no doubt Windows would be paging madly to display the images.

Please answer the questions I asked in bold above.
What do the memory stats in Task Manager look like? Post an image of the memory stats from Task Manager as I did above.
What model of SSD do you have? What capacity?
How much free space do you have on the SSD?
What does MC report about the SSD in your PC?
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Best Database Performance
« Reply #21 on: November 09, 2020, 02:22:44 am »

@RoderickGI

I'll provide the requested information later. I'm at work now.
This weekend I did many tests. The PC has been setup from the scratch with the latest Win10 image.
The SSD is a Samsung Evo 860 500GB. 4GB RAM. Quad Core CPU (4 yrs old).  Nothing else than MC is installed.

Once a view is opened, everythings runs smooth. For that job the hardware is sufficient. The problem is the time it takes to open a view.
So it is very likely that MC builds an index during the opening process. After this index is built, the thumbnails which need to be drawn, are found very quickly. 

To build that temporary index, MC obviously does many random acesses to the .JMD files in thumbnail folder. Probably there is no index and MC must do a seek for every image. In that case, the same .JMD will be read several times. As long the OS can hold that file in RAM, this works quite fast.

For testing I built a database with only 70'000 songs (a fractional part of my media).  Now everything works fluently. The largest .JMD is less than 300MB.

I tried to find reasons for my huge .JMD files.
- Once a media file is imported, the thumbnail remains in the .JMD even the File is deleted from the DB.
- Only a small part of my photos is processed and worth to be shown. These images are tagged. But import does not allow to set a filter. Therefore ALL Images will be imported. The unprocessed originals will be filtered by the views. From time to time I delete these 'originals' out of the db. But as it seems now, the thumbnails remain.


There are several ways to deal with:

1) There is a possibility to increase the RAM to 16GB. But this excludes the use of many non upgradable notebooks as Media Player.

2) Importing only a part of the Media files. But which ones ? If I'm absolutely sure that I do not want listen that specific song anymore, I could delete the media.  But who knows. Having only some files in the DB makes the concept of database obsolete.

3) Building several libraries. One for the songs, another for images and a third for the movies.
Is it possible to run several instances of MC at the same time? This would be necessary to play a song during a slide show.
Logged

flac.rules

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1260
Re: Best Database Performance
« Reply #22 on: November 09, 2020, 02:37:45 am »

I have similar problems with JRiver on large libraries, I understand some processes are not instant in large libraries, but I think it shouldn't "hang up the UI" and make the program unresponsive when these things happens, this is better than before, but still happens. (I have a SSD, defender is setup to not scan MC and so on)
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Best Database Performance
« Reply #23 on: November 09, 2020, 04:59:41 pm »

Rolf,

Your understanding of thumbnail databases and how Windows works is a little bit incorrect. MC Thumbnails databases are already highly indexed. MC has a setting to erase Thumbnails that are no longer used (orphans). If you use a PC with little memory and have a large Library, you could choose not to collect Cover Art, and hence have no Thumbnails, then still enjoy fast response and quality music. I don't know of a way to completely turn off Thumbnail generation if Cover Art exists, but you can choose to not build Thumbnails during import, so they are built as required during scrolling in Views, but that would probably be slower overall.

The bottom line is, for a Library of the size you have, with Thumbnails of 9.4GB, you need more memory so that Windows works more efficiently. Windows is absolutely thrashing your SSD to manage memory. If your SSD doesn't have lots of free space, this would make the whole situation far, far worse.  This is why I asked about free space on your SSD. Your SSD should be much, much faster than 35MB/s.

If you had answered my questions I could have confirmed that for you.

For your Library you need 16GB of memory for best performance.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

DJLegba

  • Citizen of the Universe
  • *****
  • Posts: 993
Re: Best Database Performance
« Reply #24 on: November 09, 2020, 07:14:38 pm »

The bottom line is, for a Library of the size you have, with Thumbnails of 9.4GB...

How much would it cost to buy so much material that the thumbnails folder would be 9.4GB? And if you could spend that much on music and videos, why wouldn't you have a computer with a lot more RAM?
Logged

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Best Database Performance
« Reply #25 on: November 12, 2020, 10:22:18 am »

How much would it cost to buy so much material that the thumbnails folder would be 9.4GB? And if you could spend that much on music and videos, why wouldn't you have a computer with a lot more RAM?


A large part of my media are my own photos. The costs for this are manageable  ;)
Of course I can afford bigger computers. But as a media player in the living room, I don't want a tower with 5 fans.

It turns out, that under some circumstances even 16GB are not sufficient.
Logged

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Best Database Performance
« Reply #26 on: November 12, 2020, 10:30:02 am »

@RoderickGI

Highly indexed would mean that the data is suitably prepared for the use case (the particular view). But this is precisely not the case. This preparation takes place each time a view is opened and is lost again when MC is closed at the latest.

Older laptops and the Raspberry Pi are powerful enough to play FullHD videos, high-resolution images and lossless audio. They only fail because of peak loads, which occur exactly while the user is operating. Then the GUI can get stuck for seconds to minutes.

For a company that doesn't make money from selling RAM and PCs, it should be interesting if its application runs well on as wide a range of devices as possible.


There are different solutions for this:


Save the processed data
If this prepared/sorted data could be saved on the HDD, it would only have to be generated again when the database is changed. For simple 'player' applications, modest devices are sufficient.


Sequential access to thumbnail file
Buffering HDD content is only beneficial if the same area is accessed several times. A buffer the size of the entire file is only required if it is to be expected that every area could be required at any time. On the other hand, sequential read-out in the order in which the data is stored in the file does not need a buffer, because an area that has been read is not required again.
The fact that this large buffer (free RAM) is needed proves that the accesses are not made sequentially.
With an index on the thumbnails, MC could sort the access sequence in such a way that the file is accessed in ascending order (with any gaps). and works quickly even without a RAM buffer.


Split the thumbnail files

Most views are separated into audio, video and images. Separate thumbnail files could significantly reduce their size and thus the RAM requirement. However, this fails with mixed views.
Logged

Buldarged

  • Recent member
  • *
  • Posts: 36
Re: Best Database Performance
« Reply #27 on: November 12, 2020, 02:42:51 pm »

Turning off "Show Fanned Thumbnails" fixed the performance problems for me in my 350k+ files library.
Logged

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Best Database Performance
« Reply #28 on: November 12, 2020, 03:04:13 pm »

Turning off "Show Fanned Thumbnails" fixed the performance problems for me in my 350k+ files library.

You're talking about 'Display missing files ... (slow on network drives)' ?
This option is off.

I have 380k files in the DB. Most of the time it loads well on a 16GB machine. It seems to be close to the practical limit. An update in background, other programs running and soon the memory is not enough anymore.

More memory will help. But there are other ways to read a file which do not require that much memory.
Once the file is too big to be held completely im memory, the OS must release some buffers when reading other parts. Reading the flushed parts takes longer and forces other parts to be flushed. This is easy to be verified when it happens. Go to task manager. HDD usage goes to 100% but the throughput is very low.



Logged

Buldarged

  • Recent member
  • *
  • Posts: 36
Re: Best Database Performance
« Reply #29 on: November 12, 2020, 03:39:09 pm »

No I'm talking about a different option.

Open the view with the performance problems. Klick on the tab --> Thumbnails --> Show Fanned Thumbnails and make sure there is no checkmark left to it.
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Best Database Performance
« Reply #30 on: November 12, 2020, 06:25:52 pm »

That is a good tip Buldarged.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Best Database Performance
« Reply #31 on: November 12, 2020, 07:04:31 pm »

So Rolf, you would be happy if each View in MC had its own Thumbnail database, which was built with all the images in the correct sequence for the View, so that it loaded fast in Window 10 running on 4GB of memory? Because that is what would be required based on your suggestion.

What would you want to happen if you change metadata for a few files, so that the display sequence changed? Rebuild the whole thumbnail database for that View from scratch? Again, that is what would be required. Would you be happy to wait for that?

How about when you added some new tracks to the Library, such as ripping a new CD? Wait for the rebuild?

Add another View to MC, and wait for a new thumbnail database to be built?

With several Views that show Thumbnails of media files in different sequences, requiring separate Thumbnail Databases using your suggestion, would mean that each media file had multiple copies of Thumbnails, each in different databases, and therefore taking up more disk space. With the number of Views that could be created in MC, that could end up with more disk space being used for Thumbnails than the original Cover Art file or Images. An application, in that case, would probably be better off not using a Thumbnail Database, but just reading the files directly for every display of any View. That will use much less memory, and be a whole lot slower. The concept of Thumbnail Databases was created to drastically improve the display time for large quantities of images, with minimal I/O and CPU load, by reading from one file. They are indexed files, so that images can be found and displayed quickly. Sequential loading of the files is not required. MC uses three Thumbnail Databases, for Small, Medium, and Large versions of an image, to improve further the speed. The whole concept is used in Windows itself, for icons and such, and in many, many other applications. Do you really think your idea is better?


Basically, your concept of having the thumbnail database contain images in the sequence media files are displayed in MC Views is nonsense, in the absolute meaning of that word. It is intended that MC display media in many different Views, sequences, display formats and so on. It runs on a database so that those Views display as quickly as possible. It uses three highly indexed Thumbnail Databases so that thumbnail images can be displayed quickly for the media content.


Try the tip Buldarged provided.
Reduced the size of the Cover Art display in MC using the slider, so the smaller Thumbnail Database is used instead of the larger databases.
Eliminate all Cover Art from your Library as I suggested earlier.
Delete unwanted files to minimise garbage media in the Library, and keep its size manageable.
Split out your images to a separate Library if you wish, if they are the majority of your files, so your audio/video Library isn't slowed by the images being included.


Or just upgrade you PC memory to 16GB at least, and Windows will work correctly. Because JRiver doesn't, and can't, control the way Windows does file management, paging, flushing of memory, and so on. Windows does that.


If you really think MC could work better in this area, upload a Library Backup of your Library to OneDrive, Google Drive, or similar, and share a link to it with me, via PM. I will have a look at your Views and see if there is anything that can be done to improve the performance you are seeing. It could certainly be that View definitions slow the load process considerably.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Best Database Performance
« Reply #32 on: November 13, 2020, 07:44:13 am »

So Rolf, you would be happy if each View in MC had its own Thumbnail database, which was built with all the images in the correct sequence for the View, so that it loaded fast in Window 10 running on 4GB of memory? Because that is what would be required based on your suggestion.

What would you want to happen if you change metadata for a few files, so that the display sequence changed? Rebuild the whole thumbnail database for that View from scratch? Again, that is what would be required. Would you be happy to wait for that?

How about when you added some new tracks to the Library, such as ripping a new CD? Wait for the rebuild?


Thank you for the time you take for my concern.

It is NOT my wish that every database change immediately leads to lengthy recalculations. Rather, I mean that a complex operation, once it has been carried out, does not have to be carried out again as long as nothing changes to the initial situation.

You may be underestimating the efficiency of Mediacenter. The fact is that MC runs smoothly even with a large amount of data, even with little RAM, once the view has been opened.

The RAM> 4 GB is only used during the time when the thumnails are being read. And that's only because the file is NOT read continuously in ascending order.

I only ask the question whether it would not be smarter to adjust the reading order so that the read blocks of the disc are not needed again after the next ones have already been processed. Once a buffer is not required anymore, you no longer have to complain about the buffer handling of Windows.

Buldarged's tip helps by limiting functionality / comfort. That's not the goal.

If my car doesn't pull properly because the handbrake is not fully released, then of course the problem can be avoided with more engine power. Myself, however, would rather have it resolved.

With this in mind, I hope that the programmers will check whether this peak load could not be avoided when reading the thumbnails.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 41957
  • Shoes gone again!
Re: Best Database Performance
« Reply #33 on: November 13, 2020, 08:08:39 am »

The thumbnail file can be pretty big. 

We open it with FILE_FLAG_RANDOM_ACCESS and cache any loaded thumb (and read ahead caching thumbs as well).

Since so much work happens there, it's been pretty well optimized.  There are three sizes of thumbnails in the database.

Make sure you're set to erase orphans for thumbnails on exit so junk doesn't pile up.

You could also erase all and rebuild to see if it's any better.

Obviously showing fanned thumbnails is heavier, so disabling that could be another good tip.

It's also possible slowness is something else like trying to access a NAS and is not even related to thumbs.

Please let us know if you find anything more out.  Thanks.
Logged
Matt Ashland, JRiver Media Center

leezer3

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1570
Re: Best Database Performance
« Reply #34 on: November 13, 2020, 08:25:09 am »

Some thoughts:
* Calculated fields in your views? These can slow things down especially with large amounts of stuff.
* Does it exhibit the same slowness in standard view?
Logged

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Best Database Performance
« Reply #35 on: November 13, 2020, 09:20:30 am »

The thumbnail file can be pretty big. 

We open it with FILE_FLAG_RANDOM_ACCESS and cache any loaded thumb (and read ahead caching thumbs as well).

Since so much work happens there, it's been pretty well optimized.  There are three sizes of thumbnails in the database.

Make sure you're set to erase orphans for thumbnails on exit so junk doesn't pile up.

You could also erase all and rebuild to see if it's any better.

Obviously showing fanned thumbnails is heavier, so disabling that could be another good tip.

It's also possible slowness is something else like trying to access a NAS and is not even related to thumbs.

Please let us know if you find anything more out.  Thanks.

Hi Matt

Erase orphans is selcted. But I'm pretty sure that the size of the JMD did not get smaller after I deleted the half of the DB entries. I'll check that again. Erase all Thumnails and Rebuild did the Job. If you say, there is no chance to change the read order, than it is as it is. I still like MC.


The behavior that I have described only has to do with the size of the available cache and the distribution of the thumbnails in the file. Even if the memory is insufficient, we can be lucky and the OS discards the blocks that we no longer need. In the worst case, the OS always discards exactly the block that we would need next. The practice will be somewhere in between.

Regularly rebuilding the JMD and keeping it small can help to keep the whole file in the cache. Disabling 'Fanned Thumbnails' reduces the number of thumbnails to be read. And if these are not too scattered, the RAM is more likely that they will be found in the cached blocks. All of this increases the likelihood that it can run in RAM. But there is no guarantee.

But what I can say with certainty: It has nothing to do with network access to the media. Except in the context that these can also use RAM.

If it is running smoothly, the view will open in 2-3 seconds. With the same database and installation, it can also be> 20 seconds. In that case, there is a lot of disk activity going on in the background for a long time. The data transfer rate is only a few MB / s but the activity is 100%.
If the buffer can be used optimally, the utilization is <50% and the transfer rate> 100MBs.
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 71439
  • Where did I put my teeth?
Re: Best Database Performance
« Reply #36 on: November 13, 2020, 10:03:54 am »

Here's a similar problem that was solved by configuring Windows Defender:

https://yabb.jriver.com/interact/index.php/topic,127540.msg884824.html#msg884824
Logged

Dawgincontrol

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 664
  • We have met the enemy and he is us.
Re: Best Database Performance
« Reply #37 on: November 13, 2020, 10:58:44 am »

There is a way to increase RAM using your hard drive in Windows 10. 

If you think it might help, just do a search.
Logged

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Best Database Performance
« Reply #38 on: November 13, 2020, 12:26:02 pm »

Here's a similar problem that was solved by configuring Windows Defender:

https://yabb.jriver.com/interact/index.php/topic,127540.msg884824.html#msg884824

Thank you! I am aware of the problems with Defender. I made all the exclusions. Even tests with real-time protection temporarily completely switched off showed no improvement in this regard.

I have just had this 20 second block (HDD load) on the living room computer (16GB RAM) again.  After the rebuild of the thumbnails, the largest JMD was only 5.3GB instead of 6.5GB. Now it runs smoothly again.

My collection is at the limit, even with 16GB of RAM.
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 71439
  • Where did I put my teeth?
Re: Best Database Performance
« Reply #39 on: November 13, 2020, 12:44:58 pm »

What is the full version of MC that you're using?
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Best Database Performance
« Reply #40 on: November 13, 2020, 07:00:40 pm »

If it is running smoothly, the view will open in 2-3 seconds. With the same database and installation, it can also be> 20 seconds. In that case, there is a lot of disk activity going on in the background for a long time. The data transfer rate is only a few MB / s but the activity is 100%.

With such a variation in response, perhaps you could install the Microsoft Sysinternals Process Monitor application and monitor what MC is doing with respect to "File System Activity". The tool is a bit complex, but with the right filters it can highlight issues, or at least show if it is MC thrashing the disk. I just watched MC looking up thumbnails as I scrolled a View.

Combine that with Windows Task Manager and Resource Monitor and you can get a good feel for where the I/O load is coming from. Memory usage will also be important here, because lack of free memory results in higher file system activity from paging.

I loaded up my PC by using the MC Explorer to view all files on my Working Drive, which is a lot of files, and the above tools clearly showed how much memory paging was happening even with 8GB of RAM. It also showed that once Thumbnails had been read from the drive, they weren't read again later, because, as Matt said, they had been cached. But if Windows needed some memory, those cached Thumbnails would be paged out to disk, because that is how memory management works in Windows.

With 4GB of physical memory, I think Windows 10 will allocate a Page File of about 8GB, so your Total Virtual Memory will be about 12GB. On my 8GB system Windows created a 16.5GB Page File, giving me Total Virtual Memory of 24.5GB. But 6.5GB of memory was Paged to disk even with just Chrome running, leaving 3.5GB of physical memory free. Windows memory management.

You never did answer all the questions in Reply #17 and #20.


Also, do you have Logging turned on in MC? Turn it off and see if that improves things.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

Buldarged

  • Recent member
  • *
  • Posts: 36
Re: Best Database Performance
« Reply #41 on: November 13, 2020, 07:53:22 pm »

Buldarged's tip helps by limiting functionality / comfort. That's not the goal.

I agree that there is a performance problem here regarding thumbnail loading/rendering that should not exist.
I have one subview with about 200 subviews. That means with fanned thumbnails enabled, MC has to load 1000 thumbnails, which it can't do fast enough which results in slower opening of that view and stuttering.

There are multiple problems I see:

1. Even if MC cannot load the thumbnails at the required speed, it should not stutter at all. MC should display the default icon until it has loaded the thumbnail. Loading the thumbnails should be done async with a lower priority than the UI thread is running at. Doing it that way, the view would never stutter, no matter how many thumbnails need to be loaded, although some thumbnails might not be visible immediately when opening a view or scrolling fast.

2. My library is located on a Samsung 970 Pro. A benchmark of this SSD looks like this:

MC needs to load 1000 large thumbnails for the aforementioned view. Assuming the large thumbnails are equivalent in size to the original cover art, we speak about 100KB per thumbnail. That would make 100MB in total. Reading 100KB randomly should be somewhat faster than reading 4KB randomly.
Given that the loading time is about a second I conclude that MC loads the thumbnails one after another on one thread (Q1T1). This makes sense for a hard disk, but it does not make sense for an SSD. The above benchmark shows that even with 4K random access, an SSD can achieve half of its peak performance by using multiple threads and by filling the queue with multiple requests at once. This is actually amazing. Sequential access is not necessary at all and MC has enough requests to fill the queue up. It just needs to be implemented, but that stuff is quite simple to do.

3. Opening the view and loading the thumbnails is one story. The other story is that with fanned thumbnails enabled the view is still stuttering (jumping?) when scrolling up and down. With continuous scrolling (mouse wheel button press) it is apparent that every time a new row comes into the view it stutters shortly. While scrolling upwards this effect is stronger than while scrolling downwards, at least subjectively.

4. Depending on the scaling of the view, the thumbnails have sometimes abysmal quality. In some views I need to have 4 elements in a row, because if I put 5 elements in a row it looks like a legion of gaussian blurs attacked.
Logged

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Best Database Performance
« Reply #42 on: November 14, 2020, 12:55:46 pm »

@Jim
I test every new version for performance improvement. My stable setup runs MC25.
TV and Cloud services are not relevant for me.


@Buldarged
Very interesting. This stuttering never happens in my configuration. In my photo view there is fanning activated. But even with several thousand images in one Album, it runs smoothly.
My only problem is the time when a view is opened. And this is related to audio views more than to image views.


@RoderickGI
Taskmanager shows, that MC causes that drive activities. And this is not surprising. Randomly reading from a file which is larger than the available buffer typically leads to that behaviour.
The attached image shows the read access from the thumbnail file.

Windows is not to blame. It does what it can. But windows cannot know which parts of the buffer will be used again. Most likely it will flush the buffers which haven't been used for a while. But this does not guarantee that they will not be used in the following read cycle.

Freshly created JMD files are likely to have an order that can correlate with the file order in the view. This can go well.
But it is also possible that each read request empties a buffer that is used next. The less memory we have and the more stochastic the file, the more likely it is.


Sequential reading is not affected by such buffer problems. Assuming, that MC knows the offset of the thumbnails to be read from JMD file, it could request them in ascending order.
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Best Database Performance
« Reply #43 on: November 14, 2020, 08:14:49 pm »

We open it with FILE_FLAG_RANDOM_ACCESS and cache any loaded thumb (and read ahead caching thumbs as well).

Think further on this.
Remember, every View has a different file sequence, and your PC does not have enough memory to read the whole thumbnail database sequentially as you desire.

Perhaps write down the steps you believe are happening when a View is opened in MC, describing what MC is doing, and what Windows does, as memory is filled.


Note that this is not correct. Even if it was correct for one View, it wouldn't then be correct for any other View.
Freshly created JMD files are likely to have an order that can correlate with the file order in the view.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

michael123

  • Galactic Citizen
  • ****
  • Posts: 485
Re: Best Database Performance
« Reply #44 on: November 14, 2020, 11:35:43 pm »

Thanks for all the hints. As you see in my 2nd post, my DB is stored on my local SSD. Also Win10 and MC is running from this SSD.
Files are stored on a NAS. They are accessed through SMB. A drive letter is assigned to the share.

Read/Write performance from/to NAS is fine. Clicking on a track or image opens that medie file without noticeable delay.
Database performance is poor. Opening a view with several hundred artists may take 20 seconds. The performace of the NAS should not influence that, because all DB data including the thumbnails are on my SSD.

This is nothing to do with anti-virus.
I have defender enabled on 5-6 desktops in my home including audio, it was never an issue.

What Is an issue is might be your NAS.
I have unraid system, what was helped for me a lot is having NAS online, and enabling directory cache.


Open Resource Manager while you're opening a view in JRiver and try to figure out the top 5 consumers under Disk tab
Logged

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Best Database Performance
« Reply #45 on: November 15, 2020, 06:01:55 am »

Think further on this.
Remember, every View has a different file sequence, and your PC does not have enough memory to read the whole thumbnail database sequentially as you desire.
Perhaps write down the steps you believe are happening when a View is opened in MC, describing what MC is doing, and what Windows does, as memory is filled.

There is a JMD file containing a series of thumbnails. Let's number them 1,2,3,4,5,6,7,8...
Assume the view beeing opened requires 9,7,3,2

So it is up to MC to request them in the order 9,7,3,2 or 2,3,7,9. 
In a system with no Buffer, both would be the same. But we're talking about thumbnails of 20kB size. And drives and OS read some blocks ahead. In the first example, the SSD must be accessed 4 times. In the second example only once or twice.

Reading in ascending order does not require more memory. It only requires a sorting. And this is the strength of a database.


MediaCenter runs very well. However, I have noticed that there is temporarily an extremely large memory requirement. This can overload the disk IO system.
With my tips I wanted to help the developers to eliminate this peak load, perhaps by rearranging the access sequence in the application.

And what is your intention? What are your objections useful for? Do you want to write that down too? Or explain in the sense of a discussion how you come to the conclusion that an orderly readout should need a lot of memory?
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Best Database Performance
« Reply #46 on: November 15, 2020, 07:06:54 pm »

My intentions are to educate and assist users.
You posted with a database performance problem when using a 500,000 item Library. Later you revealed that you are running MC with this Library on a PC with just 4GB of memory, and pointed out that it had 2GB free. I pointed out that it only had 2GB free because Windows was swapping much of itself out to the page file, and that with that memory restriction you are not going to get amazing performance with your Library. I recommended that you upgrade the memory to at least 16GB.

I am commenting on your posts because they are in substance mostly incorrect, and I don't want other users to think what you are saying would improve performance. If I also enlighten you, that would be a bonus.
You have ignored the advice to upgrade memory, and continue to suggest ways that MC could work better, while not having a good understanding of what MC and Windows are doing. You continue even after Matt, a senior developer at JRiver, has clarified how MC accesses Thumbnails, and has stated that this area of MC is "pretty well optimized". I assume, therefore, that you think you know better than a senior developer of MC regarding how MC could be made to work faster.

I have never said that an orderly readout should need a lot of memory. Please don't put words into my mouth.
I have said Windows 10 needs more than 4GB when running an application such as MC with a Library as large as yours. While Microsoft claims Windows 10 can run in 1GB of memory, the IT industry generally recommends a minimum of 8GB if you want to actually use your PC for anything other than simple browsing, email, and so on.
Your simple example sounds like it makes sense, and it may to some degree, particularly with look-ahead caching of thumbnails, where the thumbnail database is stored on a mechanical hard drive. On an SSD, where random reads do not depend on the movement of a read head, there is very little benefit. The benefit of doing sequential reads, if they aren't already being done by MC, rather than file displayed sequence, would be far, far less than the benefit of having more memory available. Also in my observations, MC doesn't load thumbnails in file display sequence. It loads thumbnails for whatever is visible, so a page of thumbnails, but it doesn't load top to bottom of that page. It seems somewhat random, more often from the bottom up, and probably based more on image size, hence load time.
Sequential read tests such as Buldarged shared above are contiguous sequential reads, and are therefore much faster, largely because they take advantage of look-ahead and buffering of files in fast RAM on the SSD. Accessing thumbnails from the database is not a contiguous sequential read process, even if it is a sequential read process, unless the sequence of files visible in a View exactly matches the sequence of thumbnails in the thumbnail database. That is a highly unlikely occurrence, and would only apply for one View. Any other View has a different sequence, so even sequential reads would be non-contiguous.

Your example is not a contiguous sequential read process.

Consider if your example View contained 4,000 files rather than 4, and the sequence was something like 9256, 7458, 3241, 2758, 9125, 7358, 3822, 2104, etc. Reading those files sequentially would be no better than completely random reads. There is no physical drive head to move, and while read-ahead caching for the image 3241 may result in image 3822 already being cached in memory when it was required, if there was enough memory. But there would be no guarantee that the image would still be in memory by the time is was required. If memory was limited, it may have already been paged to the drive to free up memory, and so the benefit of the read-ahead caching would be lost. If my sequence was repeated in a similar manner, and say 20 thumbnails were displayed in a View at any one time, then any benefit of sequential reading of thumbnails would be lost.

In a Library with 500,000 items, Views would contain far more than 4,000 files, and the gaps between images in the Thumbnails Database would be much larger, making the above situation far worse.


However, I have noticed that there is temporarily an extremely large memory requirement. This can overload the disk IO system.

This is the crux of the matter in your situation. While reading a large number of thumbnails will require more memory obviously, it will only require the memory to store the required images, plus a few extra thumbnails cached by the read-ahead caching, and a bit of overhead. Regardless of whether MC reads the thumbnails sequentially, it reads the individual image, based on the FileKey MC uses, the indexing in the Thumbnail Database, and hence the offset within the file to the specific location each thumbnail is stored. In order to display those thumbnails in MC, a certain minimum amount of memory is required. Your disk I/O system is being overloaded as Windows needs to page out a lot of memory to disk, and then pull it back again, constantly, whenever you do anything in MC.

Essentially, factors other than the read sequence of images from the Thumbnail database are more important in your situation. Factors such as available memory, Windows paging memory to the drive, and reading the page file back to memory, size of the Library, the quantity of thumbnails visible at any time in a View, read-ahead caching of images by MC, and size of images (hence memory usage).


I have no doubt that Thumbnailing in MC could be improved, particularly on modern SSDs that allow multiple simultaneous files reads. But the most obvious improvement would be to make MC even more multithreaded. However, that would require more processes to be running, and hence more memory to be available.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 71439
  • Where did I put my teeth?
Re: Best Database Performance
« Reply #47 on: November 15, 2020, 08:41:21 pm »

I am commenting on your posts because they are in substance mostly incorrect, and I don't want other users to think what you are saying would improve performance.
I agree.  Rolf, please stop.
Logged

rolf_eigenheer

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 303
  • nothing more to say...
Re: Best Database Performance
« Reply #48 on: November 17, 2020, 08:57:23 am »

Hi Roderick

You are right, the reading order cannot be the cause of the problem mentioned. In my audio view, surprisingly few thumbnails are shown. And even fewer are shown on the screen at the same time. No matter in which order or completely randomly - an SSD is always fast enough to deliver this data.
So, as you recommended, I used the Sysinternals Process Monitor to see what was happening when the view was opened.


At the beginning I described that my DB contains 500,000 entries. In the course of the tests, I eliminated data types that I never need in the DB. There are now around 350,000 entries.

130,500 pieces of music, audio books and podcasts
214,000 photos
5,500 videos

My Artist View shows 43,000 tracks from 3700 albums by 535 artists. A total of 3700 x 25kB can be read from the 'Thumbnails (large).JMD' file. This results in 535 fanned stacks of images. These 535 stacks, saved as 535 images, would occupy less than 15MB in total and allow scrolling through the view without having to access the disc again.

But even if the images aren't in RAM yet, that's not a big deal. On the screen you can see maybe 50 artists at the same time, which in total stand for maybe 400 albums.
So 400 x 25kB thumbnails have to be read from the JMD. That's only 10MB. An SSD hardly needs more than 100 milliseconds for this, even with random access.

The question that now arises is: Why is a 4-core computer with SSD and 4GB RAM not enough to open this view in less than a second? Why can even a 16BGB computer be completely occupied with SSD access for up to 20 seconds, so that scrolling is not possible?
It can hardly be assumed that a database fails to filter out of 14,000 albums (including photo albums) those that match the artists to be displayed.

The most plausible explanation so far is the memory management with swapping in and swapping out of pages. The buffers managed by the OS are particularly problematic. The OS cannot know whether the data will be used again. If the memory is no longer sufficient to buffer everything that has ever been read from the disk, then it is pure chance what is released. The application, on the other hand, knows what it makes sense to keep in RAM. And as shown, this is very little.

When I open the Artist View (Theater Mode), 'Microsoft Sysinternals Process Monitor' shows 220,000 read accesses to the JMD file for 16 bytes each with intervals of around 25 kB in ascending order. This reads header information for the individual thumbnails. When the next block is requested, the previous one is no longer needed. But MC opens this file with the flag for 'RANDOM ACCESS'. Windows must then assume that access can take place anywhere at any time and tries to keep every block read in RAM. That is the reason for the large memory requirement. In my case, the 5GB JMD is actually read from start to finish, including the 32kB gaps between every 16B block, which are nothing other than the actual thumbnails. Because all of this takes place without a break, the OS must assume that this file is still needed. This then inevitably also requires 5GB of RAM. And where that is not free, complex swapping begins.
When reading is finished and Windows comes to the conclusion that the buffer is probably not needed after all, then it runs very smoothly again.

In summary:

So it is wrong to say that a large DB necessarily requires a lot of free RAM. Only the above process uses RAM unnecessarily and thus paralyzes the whole system.

Second, the hardware available today guarantees very short response times even without buffering. Buffers can bring further acceleration. But under no circumstances should the buffer management ultimately lead to a degradation of the system.
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3966
Re: Best Database Performance
« Reply #49 on: November 17, 2020, 04:53:56 pm »

I was about to post that it makes little sense to me to have all that data in memory given that we're basically talking about a viewport but then I refreshed and saw Rolf has posted a much longer and more detailed version of that :)

fwiw googling for FILE_FLAG_RANDOM_ACCESS performance gives a bunch of hits that sound like this thread, bit hard to square this with being a lean/well optimised component of MC as opposed to something that degrades catastrophically under load. I also agree with the point that there is no reason why a large library should require a load of RAM to operate, I would think that a large library + a weak cpu is something that could be slow going but the database itself is surely still small relative to even 2G of RAM isn't it?
Logged
Pages: [1] 2   Go Up