xbmc/xbmc — pull request #3676 by bavison (2013-11-18 16:12:02+00:00)
Title: Add selective caching of infobools in list items

As noted in a TODO comment attached to CGUIInfoManager::GetBoolValue, caching
of infobools (both expression and single bools) is disabled whenever a
CGUIListItem pointer is provided. This is true whenever visibility is
evaluated for a control which is part of a list item (which is responsible
for a large portion of the controls in many windows), which obviously hurts
caceh efficiency. However, many of the bools (including the leaf nodes of
expression infobools) aren't actually dependent upon which list item they're
attached to.

This patch adds a flag to each InfoBool object to indicate whether its value
depends upon the list item; if this isn't set, then the cache is re-enabled
even if a CGUIListItem pointer is provided. The flag is calculated at parse
time because it's quite tricky to evaluate - it applies to bools in any of
the following categories:
* a statically definied boolean condition in the range LISTITEM_START to
LISTITEM_END - for example, "ListItem.IsResumable"
* a (dynamically allocated) multi-info bool, that is to say, the result of a
string or integer operation on a list item attribute - for example
"substring(Listitem.mpaa,Rated R)"
* an expression that uses one or more of the above - for example
"Window.IsVisible(Videos) + !ListItem.IsResumable"

I measured the effect while the Videos window of the default skin was open
(but idle) on a Raspberry Pi, and this reduced the CPU usage by 3.2% from
45.1% to 41.9%:

Before After
Mean StdDev Mean StdDev Confidence Change
IdleCPU% 45.1 1.2 41.9 0.5 100.0% +7.7%