[Rejected] - Reduce check interval of PowerScheduler

Discussion in 'Archive' started by Oxan, January 20, 2012.

  1. Oxan
    • Team MediaPortal

    Oxan Retired Team Member

    Joined:
    August 29, 2009
    Messages:
    1,730
    Likes Received:
    1,024
    Gender:
    Male
    Ratings:
    +1,115 / 2
    Home Country:
    Netherlands Netherlands
    See bug report here. It boils down to a loop that fires each second in the PowerScheduler, which causes a unnecessary burden on the CPU. See this post for a patch (copied below); I can push a Git branch or create a pull request too if wanted.



    Code (Text):
    1. commit a9e50a7afe3d40fa2670c316d339ad5fd4f4a2de
    2. Author: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl>
    3. Date:  Tue Jan 3 23:10:30 2012
    4.  
    5.     PowerScheduler: Do not poll at one second intervals
    6.  
    7.     This is a totally unnecessary load on the system
    8.  
    9. diff --git a/TvEngine3/TVLibrary/Plugins/PowerScheduler/PowerScheduler.cs b/TvEngine3/TVLibrary/Plugins/PowerScheduler/PowerScheduler.cs
    10. index 365337a..0fd79e5 100644
    11. --- a/TvEngine3/TVLibrary/Plugins/PowerScheduler/PowerScheduler.cs
    12. +++ b/TvEngine3/TVLibrary/Plugins/PowerScheduler/PowerScheduler.cs
    13. @@ -825,32 +825,29 @@ namespace TvEngine.PowerScheduler
    14.         Log.Error("Powerscheduler: Error naming thread - {0}", ex.Message);
    15.       }
    16.  
    17. -     int reload = 0;
    18. +     LogVerbose("Looping in intervals of {0} seconds", PowerSettings.CheckInterval);
    19. +
    20.       do
    21.       {
    22.         if (!_standby)
    23.         {
    24.           try
    25.           {
    26. -           if (reload++ == _reloadInterval)
    27. -           {
    28. -             reload = 0;
    29. -             CheckForStandby(true);
    30. -             // Clear cache
    31. -             CacheManager.Clear();
    32. -             GC.Collect();
    33. -             LoadSettings();
    34. -             SendPowerSchedulerEvent(PowerSchedulerEventType.Elapsed);
    35. -           }
    36. -           else
    37. -             CheckForStandby(false);
    38. +           CheckForStandby(true);
    39. +
    40. +           // Clear cache
    41. +           CacheManager.Clear();
    42. +           GC.Collect();
    43. +           LoadSettings();
    44. +
    45. +           SendPowerSchedulerEvent(PowerSchedulerEventType.Elapsed);
    46.           }
    47.           catch (Exception ex)
    48.           {
    49.             Log.Write(ex);
    50.           }
    51.         }
    52. -       if (_stopThread.WaitOne(1000)) // Wait one sec / exit
    53. +       if (_stopThread.WaitOne(PowerSettings.CheckInterval * 1000)) // Wait one sec / exit
    54.         {
    55.           LogVerbose("Powerscheduler poll thread - exit");
    56.           return;
    57.  
     
    Last edited by a moderator: March 15, 2013
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. Oxan
    • Team MediaPortal

    Oxan Retired Team Member

    Joined:
    August 29, 2009
    Messages:
    1,730
    Likes Received:
    1,024
    Gender:
    Male
    Ratings:
    +1,115 / 2
    Home Country:
    Netherlands Netherlands
    Turned out that this broke the PowerScheduler on WinXP, so not merged.
     
Loading...

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

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!