[WiP] - Log performance improvements

Discussion in 'Submit: code patches (MediaPortal/TV-Server/etc.)' started by Neos, March 7, 2011.

  1. Neos

    Neos Portal Member

    Joined:
    February 14, 2008
    Messages:
    18
    Likes Received:
    15
    Ratings:
    +15 / 0
    Home Country:
    Netherlands Netherlands
    This patch's main intent is to improve the performance of the one method that is, obviously, called the most throughout any application. It changes the ILog interface removing the params object[] args from each of the logging methods: Info, Error, Warn and Debug. Internally when not specifying any arguments the compiler generates an empty object array for you. The framework's developers optimized calls to such methods by overloading them with a default of 3 extra arguments (see Console.WriteLine or String.Format). For an log-line that requires less than 3 arguments this is about 3-4 IL instructions less. Adding extra overloads is simple and truly worth the performance gain, especially in projects that make extensive use such of the params keyword.

    When the callee does require formatting of his log a new set of overloads has been added to the static Log classes in MediaPortal.ServiceImplementations and MediaPortal.GUI.Library. These overloads call string.Format passing the formatted string to the actual instance of the ILog interface. For each log method 3 overloads exists fully exploiting the the string.Format optimizations in the Framework.

    In addition I have removed several direct calls to the GlobalServiceProvider class in favor of the static log classes. The USBUIRT Plugin kept a local reference to the the central ILog interface, this has also been replaced with a call to the static log class.

    Edit: In all my I forgot one crucial thing, still in essence this patch should improve performance be it not that the formatting isn't done when for messages not written to the log. My patch does (sadly enough), at this point in time, always format text even if it is not logged. Rather careless of me to to this before submitting my patch. Tomorrow I will provided a better version that DOES do what it should do.


     

    Attached Files:

    • Like Like x 4
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. revs
    • Premium Supporter

    revs MP Donator

    Joined:
    February 1, 2007
    Messages:
    1,274
    Likes Received:
    72
    Occupation:
    Software Developer
    Location:
    The Sauce of Worcester
    Ratings:
    +72 / 0
    Home Country:
    Wales Wales
    4 posts so far, and each one has been a bugfix/code optimization - great work! :D
     
  4. SilentException
    • Premium Supporter

    SilentException Retired Team Member

    Joined:
    October 27, 2008
    Messages:
    2,617
    Likes Received:
    1,125
    Gender:
    Male
    Location:
    Rijeka, Croatia
    Ratings:
    +1,129 / 0
    Home Country:
    Croatia Croatia
    Yup, thanks so much Neos. But the patches will have to wait until 1.2 is released. We're in the future freeze.

    Bug fixes are still allowed to go in, so if you try to separate bug fixes from optimizations/features, I'll try to take a look ASAP.
     
  5. disaster123
    • Premium Supporter

    disaster123 MP Donator

    Joined:
    May 14, 2008
    Messages:
    3,546
    Likes Received:
    417
    Ratings:
    +431 / 2
    Home Country:
    Germany Germany
    AW: Log performance improvements

    SilentException
    wouldn't it then make sense to make already a branch for 1.2 so that patches can still go into trunk?
     
  6. SilentException
    • Premium Supporter

    SilentException Retired Team Member

    Joined:
    October 27, 2008
    Messages:
    2,617
    Likes Received:
    1,125
    Gender:
    Male
    Location:
    Rijeka, Croatia
    Ratings:
    +1,129 / 0
    Home Country:
    Croatia Croatia
    Not really, if anything it would slow our already (too) long release cycle even more. At this point we need to concentrate on finding and fixing any bugs and not on new features. Sadly, closing trunk (feature freeze) is only option to somehow force developers to do that.
     
    • Like Like x 1
  7. Neos

    Neos Portal Member

    Joined:
    February 14, 2008
    Messages:
    18
    Likes Received:
    15
    Ratings:
    +15 / 0
    Home Country:
    Netherlands Netherlands
    No problems, I must say this is indeed more of a performance feature then bug fix. I'll seperate it into a bug fix and repost the improved performance feature for the log later.

    Edit: Added a patch that fixes several classes that accessed the log through the GlobalServiceProvider class instead of the static Log class.
     

    Attached Files:

    • Like Like x 2
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!