[Approved] patch to speed up shares view (1 Viewer)

xsiv4ce

Portal Member
February 28, 2009
8
5
I've been using MediaPortal a lot lately and while I like it for the most part, I noticed that it was quite slow reading directory information over the network. Others have posted about this problem also, so I thought I'd look into it.
Here is what I came up with - instead of using .NET to get the directory information, I use the win32 api directly and get the file attributes that way - this keeps the code from going to the drive multiple times for each file and speeds it up quite a bit, but I also took out the SetThumbnails calls which are also very inefficient and seem to be redundant.

I've been running it on my system for a couple of weeks and it has been stable and navigating the folders is much faster - maybe 10 times faster.
 

Attachments

  • HandleLocalFilesInDir.patch
    30.7 KB

rtv

Retired Team Member
  • Premium Supporter
  • April 7, 2005
    3,622
    301
    Osnabruck
    Home Country
    Germany Germany
    Thumbs might be missing here and there with it.
    The team already put some effort into "shares" browsing and investigated solutions like running unsafe code as well for a performance speedup.
    Unfortunately all of them had some serious drawbacks - e.g. delays if it comes to offline shares, lock problems on non windows shares (Samba/NFS) and similar.
    There are just too many different scenarios for a small development team to cover all potential breakings. The System.IO namespaces "should" cover _every_ situation which might be possible and that's the reason why they might be slower.

    Finally you should be using the database views as often as possible (even more if you just have a wireless connection).
     

    xsiv4ce

    Portal Member
    February 28, 2009
    8
    5
    Thanks Migue - are the thumbs ok in MyPictures and MyMusic though? I think I had thumbnail creation turned off for MyVideos since it was causing other problems so I didn't notice a difference there. I can enable it for MyVideos and leave it off for MyPictures and MyMusic (where most people probably have the most files) and eventually add another patch to load the thumbs in a background thread the way its done in MyPictures..

    Hi RTV - I've used the database view as well and I know this is what has been recommended to people who complained about the performance before, but I still prefer the shares view since there are no problems with keeping the database in sync. Also not all music files have ID3 tags so some of them don't even show up in the database view.
    I think using the .NET DirectoryInfo function vs the win32 Find functions is not going to make a difference with locked files and offline shares - you're going to run into delays either way if a directory or a file is locked or if the share is offline.. I am running SAMBA by the way and haven't run into any problems..
     

    xsiv4ce

    Portal Member
    February 28, 2009
    8
    5
    no place for a 10x speed improvement eh? well don't be sorry for me for not getting my patch through but for the users who have to wait for MP to grind through each time they change a directory. Also, switching to Win7 or Vista is not going to make up for the inefficiency of the existing code - I have tried both Vista and Win7 but on my machine, XP runs the fastest.. I definitely would not recommend anyone going to Vista.
    I know that most of the MP code is written in .NET and probably most of the developers working on it are most comfortable with that.. but not taking the patch because it is not .NET (it is "unsafe" code) and because .NET should "cover _every_ situation" since its the latest and greatest thing that Microsoft is pushing is a bit of cop out..
     

    technick

    Portal Pro
    May 6, 2009
    566
    155
    Home Country
    France France
    Agree, I use Vista and a Freenas server, when you play a divx on server the video start in thumbnail and you wait 2 minute before full screen (and can do nothing, just wait). When you have a big (more than 200 files) directory on network it's start to be a real problem. Solution for me could be the myfilm plugin (I want test it for this). When I use windows the video start instantaneously. The problem is that many people start to have servers at home and that a htpc with many disk make noise (and raid 5 more because all disks turn). This is also for me (and some of my friends) a problem to solve.

    edit :
    YES ! Tested on a private SVN 24039 and now I can open a divx without problem on a 800+ files directory on my Freenas Server (0.7RC2 Khasadar). I confirm that it's a really good patch. Perhaps it can be implemented as a option to make agree everyone ? Becarefull, I know http://www.ipetitions.com ;-)

    edit2:
    Perhaps a idea but I found that the HD TV video is better, no difference between my sony TV & mediaportal, without this patch and since divx codec don't work anymore the mediaportal HD TV was not perfect. Read/write optimisations seems to be not only good for scanning directory.

    Edit3:
    Not tested the thumb bug
    Mediaportal 1.1.0 ALPHA SVN 24039 Patched : http://rapidshare.com/files/302439997/24039.rar.html
     

    technick

    Portal Pro
    May 6, 2009
    566
    155
    Home Country
    France France
    Thanks again xsiv4ce.

    I just modify your patch to add it in General config so if someone want go slowly in compatibility mode, he can ;-)

    I'm not a professional developper in C# so I make simple.

    If you have not a compiler I make you a SVN compil

    THIS IS A UNOFFICIAL PERSONNAL BUILD, DON'T REPORT BUGS ELSEWHERE !
    ----------------------------------------------------------------------------------------------
    Mediaportal SVN 24081 : RapidShare: 1-CLICK Web hosting - Easy Filehosting
     

    xsiv4ce

    Portal Member
    February 28, 2009
    8
    5
    thanks for the help Technick. It sounds like your setup is very similar to mine - I am running Freenas as my file server also. I upgraded my LAN from 100 megabit to 1 gigabit hoping that it would improve the directory search times, but it didn't make a bit of difference, so I knew that the slowness was not due to the speed of the network.
    I think adding this patch as an option in the settings is a good idea..
     

    Users who are viewing this thread

    Top Bottom