This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

/!\ Warning:
This is only a proposal at this time, and not approved for project-wide application.
This should not be applied before being officially turned into a GNOME Goal.

GNOME Goal: Use g_timeout_add_seconds instead g_timeout_add

Summary

From http://gould.cx/ted/blog/Saving_the_world_one__w_at_a_time and https://wiki.ubuntu.com/SavingTheWorld

One of the features of Glib is that it provides two timeout functions: g_timeout_add and g_timeout_add_seconds. The difference is much more important than not having to add a "* 1000" in one and not the other. The important thing that the second function does is that it tried to group wake-ups to ensure that the program wakes up as little as possible. This is never perfect, but it's a small thing that can help to save some power and reduce the number of wake-ups.

Guidelines

So if you'd like to help save a little power on your machine, follow these instructions.

  1. Take one of the packages in the Gnome git repository: http://git.gnome.org

    • $ git clone git://git.gnome.org/<package>

  2. Branch it to work on your local branch:
    • $ git checkout -b <new_branch>

  3. Find the instances that might be causing the problem.
    • $ git grep "timeout_add "

  4. Replace g_timeout_add for g_timeout_add_seconds ( see the comments below )

  5. Commit and generates the Changelog: (for the Changelog format see http://live.gnome.org/Git/CommitMessages)

    • $ git commit -a

  6. Generate a patch:
    • $ git format-patch HEAD~1

  7. Submit a bug report with the patch to http://bugs.gnome.org/

Comments before approval

{i} Add your comments to this goal proposal here

PaoloBorelli: the instructions should make clear that the goal is not about finding all instances of g_timeout_add and blindly replacing them: only in some cases the function should be replaced with the add_seconds variant otherwise we would have simply fixed the g_timeout_add implementation. In particular the candidates for beeing replaced are timeouts called in a recurrent manner (eg polling) and that do not need an accurate timeout. Timeouts that are fired just once or that result in something visible to the user should usually not be changed. Obviusly things need to be evaluated case by case.


Comments from Emmanuele Bassi in bug #581258 (comment #4):

timeout_add_seconds() is meant to be used to cause the minimum amount of wakeups and let the kernel coalesce multiple wakeups at the same time. this means that a 5 seconds timeout might actually occur at the (worst case scenario) 7 seconds marker, if other timeouts are scheduled for that delay.

I'd agree with Paolo that timeouts that are invoked just once do not pose a significant difference, but I'd love to get an informed opinion from the kernel people.


Comments from HavocPennington in bug #573718 (comment #6):

"I think add_seconds should be used when:

If the timeout callback returns TRUE that keeps the timeout installed; if FALSE that removes the timeout. So if a timeout returns FALSE, usually it is not a recurring timeout."

Status of this goal

/!\ Note: Updated automatical stats can be found at http://www.gnome.org/~fpeters/reports/g_timeout_add.html

{i} Tip: If you choose to work on a module, create the bug report on the GNOME bugzilla. This way people will know someone already works on it, and won't duplicate the work you're doing.

State

Markup

todo

<: #ff8080> todo

patch

<: #ffc849> [[GnomeBug:xxxxx|patch]]

done

<: #80ff80> [[GnomeBug:xxxxx|done]]

not needed

<: #80ff80> not needed

Above are the states and corresponding markup to update the modules state table below.

Tarball

Status

Desktop

alacarte

not needed

brasero

done

bug-buddy

not needed

cheese

not needed

dasher

not needed

deskbar-applet

done

ekiga

done

empathy

not needed

eog

not needed

epiphany

not needed

evince

not needed

evolution-data-server

done

evolution

done

evolution-mapi

to do

evolution-webcal

not needed

file-roller

to do

gcalctool

not needed

gconf-editor

not needed

gdm

done

gedit

done

gnome-applets

done

gnome-backgrounds

not needed

gnome-control-center

patch

gnome-desktop

not needed

gnome-desktop-sharp

not needed

gnome-doc-utils

not needed

gnome-games

done

gnome-icon-theme

not needed

gnome-keyring

not needed

gnome-netstatus

to do

gnome-nettool

to do

gnome-mag

to do

gnome-media

done

gnome-menus

not needed

gnome-panel

done

gnome-power-manager

done

gnome-python-desktop

not needed

gnome-screensaver

done

gnome-session

patch

gnome-settings-daemon

done

gnome-sharp

not needed

gnome-speech

patch

gnome-system-monitor

done

gnome-system-tools

to do

gnome-terminal

not needed

gnome-themes

not needed

gnome-user-docs

not needed

gnome-user-share

to do

gnome-utils

patch

gok

not needed

gstreamer

patch

gst-plugins-base

patch

gst-plugins-good

patch

gtk-engines

to do

gtkhtml

to do

gtksourceview

done

gucharmap

patch

gvfs

done

hamster-applet

not needed

libgail-gnome

not needed

libgnomekbd

to do

libgtop

not needed

libgweather

not needed

liboobs

not needed

librsvg

not needed

libsoup

not needed

libwnck

patch

metacity

done

mousetweaks

to do

nautilus

done

orca

not needed

pygtksourceview

not needed

seahorse

done

sound-juicer

to do

swfdec-gnome

not needed

tomboy

not needed

totem

done

totem-pl-parser

not needed

vinagre

done

vino

done

vte

to do

yelp

patch

zenity

done

Desktop (to be deprecated)

libgnomeprint

to do

libgnomeprintui

to do

Platform

GConf

done

at-spi

not needed

atk

not needed

glib

patch

gtk+

patch

gtk-doc

not needed

pango

not needed

Platform (to be deprecated)

ORBit2

to do

audiofile

to do

esound

to do

gnome-mime-data

to do

gnome-vfs

to do

gnome-vfs-monikers

to do

libIDL

to do

libart_lgpl

to do

libbonobo

to do

libbonoboui

to do

libglade

not needed

libgnome

to do

libgnomecanvas

to do

libgnomeui

to do

Admin

pessulus

not needed

sabayon

done

Development Tools

accerciser

not needed

anjuta

done

devhelp

not needed

gdl

not needed

glade3

done

gnome-devel-docs

to do

Bindings (C++)

glibmm

to do

pangomm

not needed

gtkmm

not needed

libglademm

not needed

gconfmm

not needed

libgnomecanvasmm

to do

libgnome-vfsmm

to do

libgnomemm

to do

libgnomeuimm

to do

libxml++

not needed

Bindings (java)

glib-java (jg-common)

to do

libgtk-java

to do

libgnome-java

to do

libgconf-java

to do

libglade-java

to do

Bindings (mono)

gtk-sharp

not needed

Bindings (perl)

Glib

to do

Gtk2

to do

Gtk2-GladeXML

to do

Gnome2-GConf

to do

Gnome2-Canvas

to do

Gnome2-VFS

to do

Gnome2

to do

Bindings (python)

pygobject

not needed

pygtk

not needed

pyorbit

not needed

gnome-python

not needed

Mobile

GConf (dbus-based)

to do

evolution-data-server (dbus-based)

to do

clutter-gst

to do

External Dependencies

avahi

to do

cairo

not needed

cairomm

not needed

clutter

to do

clutter-cairo

to do

clutter-gtk

to do

conduit

to do

dbus

to do

dbus-glib

to do

dbus-python

done

all test/example code

desktop-file-utils

not needed

Devicekit-power

to do

enchant

not needed

expat

to do

farsight2

to do

fontconfig

not needed

gamin

to do

gnutls

not needed

gpgme

to do

gtk-vnc

to do

hal

to do

hicolor-icon-theme

not needed

icon-naming-utils

not needed

intltool

not needed

iso-codes

not needed

libcanberra

not needed

libcolorblind

not needed

libcroco

not needed

libgda

to do

libggz, ggz-client-libs

not needed

libgpg-error

not needed

libgcrypt

not needed

libgsf

not needed

libical

not needed

libmapi

to do

libmusicbrainz

not needed

libnotify

patch

liboil

not needed

libproxy

not needed

libtasn1

not needed

libtelepathy

to do

libxklavier

not needed

libxml2

to do

libxslt

to do

Mono.Addins

not needed

mozilla (firefox)

to do

ndesk-dbus

not needed

ndesk-dbus-glib

not needed

opal

not needed

pkg-config

to do

PolicyKit

to do

PolicyKit-gnome

to do

pulseaudio

not needed

poppler

not needed

pycairo

not needed

ptlib

not needed

Python

to do

rarian

not needed

shared-mime-info

not needed

sqlite

not needed

startup-notification

not needed

swfdec

to do

system-tools-backends

not needed

telepathy-glib

patch

telepathy-mission-control

patch

unique

to do

Other

atomix

not needed

banshee

to do

banter

to do

beagle

to do

contact-lookup-applet

to do

dia

done

eggcups

to do

f-spot

not needed

gnome-blog

to do

gnome-bluetooth

not needed

gnome-cups-manager

to do

gnome-main-menu

to do

gnome-mud

to do

GParted

to do

GNOME Phone Manager

to do

Gnumeric

to do

gossip

to do

gtetrinet

to do

gthumb

to do

gtranslator

to do

libbtctl

to do

libgda

not needed

libgnomekbd

to do

libgoffice

to do

libgsf

not needed

nautilus-sendto

done

nautilus-vcs

to do

nemiver

not needed

NetworkManager

to do

network-manager-applet

done

Planner

done

rhythmbox

to do

xchat-gnome

done


2024-10-23 11:17