| 1 |
.. _caching: |
| 2 |
|
| 3 |
Power and Caching |
| 4 |
================= |
| 5 |
|
| 6 |
When a lot of widgets are in use they, and awesome, can generate a lot |
| 7 |
of wake-ups and also be very expensive for system resources. This is |
| 8 |
especially important when running on battery power. It was a big problem |
| 9 |
with awesome v2 and widgets that used shell scripts to gather data, |
| 10 |
and with widget libraries written in languages like Ruby. |
| 11 |
|
| 12 |
Lua is an extremely fast and efficient programming language, and Vicious |
| 13 |
takes advantage of that. But suspending Vicious widgets is one way |
| 14 |
to prevent them from draining your battery, despite that. |
| 15 |
|
| 16 |
Update intervals also play a big role, and you can save a lot of power |
| 17 |
with a smart approach. Don't use intervals like: 5, 10, 30, 60, etc. |
| 18 |
to avoid harmonics. If you take the 60-second mark as an example, |
| 19 |
all of your widgets would be executed at that point. Instead think about |
| 20 |
using only prime numbers, in that case you will have only a few widgets |
| 21 |
executed at any given time interval. When choosing intervals also consider |
| 22 |
what a widget actually does. Some widget types read files that reside |
| 23 |
in memory, others call external utilities and some, like the mbox widget, |
| 24 |
read big files. |
| 25 |
|
| 26 |
Vicious can also cache values returned by widget types. Caching enables you |
| 27 |
to have multiple widgets using the same widget type. With caching its worker |
| 28 |
function gets executed only once---which is also great for saving power. |
| 29 |
|
| 30 |
* Some widget types keep internal data and if you call one multiple times |
| 31 |
without caching, the widget that executes it first would modify stored values. |
| 32 |
This can lead to problems and give you inconsistent data. Remember it |
| 33 |
for widget types like CPU and Network usage, which compare the old set |
| 34 |
of data with the new one to calculate current usage. |
| 35 |
* Widget types that require a widget argument to be passed should be |
| 36 |
handled carefully. If you are requesting information for different devices |
| 37 |
then caching should not be used, because you could get inconsistent data. |