home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Development
Submit: code patches (MediaPortal/TV-Server/etc.)
Log performance improvements
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Neos" data-source="post: 721449" data-attributes="member: 67572"><p>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 <u>params object[] args</u> 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 <u>params</u> keyword.</p><p></p><p>When the callee does require formatting of his log a new set of overloads has been added to the static Log classes in <u>MediaPortal.ServiceImplementations</u> and <u>MediaPortal.GUI.Library</u>. 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.</p><p></p><p>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.</p><p></p><p><strong>Edit:</strong> 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.</p></blockquote><p></p>
[QUOTE="Neos, post: 721449, member: 67572"] 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 [U]params object[] args[/U] 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 [U]params[/U] keyword. When the callee does require formatting of his log a new set of overloads has been added to the static Log classes in [U]MediaPortal.ServiceImplementations[/U] and [U]MediaPortal.GUI.Library[/U]. 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. [B]Edit:[/B] 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. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
Submit: code patches (MediaPortal/TV-Server/etc.)
Log performance improvements
Contact us
RSS
Top
Bottom