[Approved] - Recording Conflicts Optimization

Discussion in 'Archive' started by romadd64, March 1, 2011.

    • Premium Supporter

    romadd64 MP Donator

    When you set a new scheduled recording, tvplugin checks conflicts with other schedules.
    The check can be very slow, especially when there is a combination of :

    - multiseat setup and the new schedule is set on a client
    - many tuners
    - the new schedule has multiple episodes (record every...)
    - many schedules already present with multiple episodes
    - many channels with EPG across multiple days


    This patch introduces an optimization of the above check, and other bugfix/functionality :

    - optimization in GetConflictingSchedules(), search only between overlapping episodes
    - optimization in canViewTvChannel() and canTuneTvChannel(), create channel map only for current channel
    - bugfix, ConflictsManager should not use disabled cards for schedule allocation. It should not use also not present cards, but not implemented because I'm not sure the best way to do it
    - bugfix, ConflictsManager should check if schedule channel isn't mapped to a card, added user interaction like with episodes conflict


    romadd

    Attached Files:

    • Like Like x 5
  1. Neos Portal Member

    You can further optimize the code by instancing DateTime.Now instead of calling it repeatedly:
    Code (text):
    DateTime now = DateTime.Now;
    and replace all calls to 'DateTime.Now' by 'now'

    Also you should not use the out parameter on an argument you already assigned:
    Code (text):
    List<Schedule> conflicts = new List<Schedule>();
    List<Schedule> notViewables = new List<Schedule>();
    layer.GetConflictingSchedules(schedule, out conflicts, out notViewables);
    Should instead be:
    Code (text):
    List<Schedule> conflicts;
    List<Schedule> notViewables;
    layer.GetConflictingSchedules(schedule, out conflicts, out notViewables);
    Out variables used as out-parameters should never be assigned. You assign them in the method 'GetConflictingSchedules'. The JIT might optimize this for you but if it does not (and it doesn't do much to much aggressive optimizations) you just created 2 lists which are destroyed once you call GetConflictingSchedules(). You can either use the lines I purposed or remove the 'out' parameters and not create the lists in GetConflictingSchedules().
    • Like Like x 2
    • Premium Supporter

    disaster123 MP Donator

    AW: Recording Conflicts Optimization

    romadd64
    nice patch - which solves a lot of waiting for me. Also working fine here. Could you please fix the bugs/faults which Neos has found?
    • Premium Supporter

    romadd64 Thread Starter MP Donator

    I will post in a few days a modified patch with optimizations suggested by Neos.
    Now I'm working on another patch.

    romadd
    • Premium Supporter

    disaster123 MP Donator

    AW: Recording Conflicts Optimization

    Any news? This patch is great as it reduces scheduling recordings a lot.
    • Team MediaPortal

    miroslav22 Development Group Member

    we might be able to create additional indexes on columns in the database to further enhance this. I'll take a look in the next few days
    • Premium Supporter

    disaster123 MP Donator

    AW: Recording Conflicts Optimization

    Oh that's also a good idea - never logged all queries not using indexes with mediaportal. But perhaps somebody should look at this in general.
    • Team MediaPortal

    jameson_uk Lead Dev MP1 Music

    System Specs
    Might make a difference but most likely will not. The main thing here is that the lookup is itterating over too many loops. The fact we are using a sort of ORM (GENTLE) means that queries tend to be "give me the list of cards" and then we itterate over that list saying well for this card give me the list of channels then for these channels give me the tuning details...

    The volume of data and type of query means that indexes are unlikely to help. The real thing here is to cut down the amount of loops
    • Team MediaPortal

    miroslav22 Development Group Member

    yea it depends on the volume of data and the number of queries. At the moment the number of queries increases exponentially as the number of schedules grows (eg double the number of schedules and you could have 50x more queries executed in total) .

    I usually have a lot of epg entries at any one time (~150,000) so i'll try benchmarking with additional indexes.
    • Premium Supporter

    disaster123 MP Donator

    AW: Recording Conflicts Optimization

    But the initial path schould still getting checked - it reduced scheduling for me from 10-30s down to 5s.

Share This Page

Users Viewing Thread (Users: 0, Guests: 0)

Running the latest version?

V1.3.0 FINAL - released March 2013
Releasenews | Download
Changelog
 | Requirements
HTPC
Team-MediaPortal
 
About
Contact |  Press
Partners