From kde-core-devel Thu Sep 21 12:06:49 2006 From: Lubos Lunak Date: Thu, 21 Sep 2006 12:06:49 +0000 To: kde-core-devel Subject: Re: Caching local time zone Message-Id: <200609211406.50254.l.lunak () suse ! cz> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=115884044529385 On Thursday 21 September 2006 11:04, David Jarvie wrote: > Using KDateTime for date/times in the local time zone can potentially > result in very frequent calls to KSystemTimeZones::local() which fetches > and returns the current local system time zone. Depending on the system, > that function may open and read files, and compare their contents. Even if > the files are still cached (as would usually be the case on a UNIX system > when the function calls are made in quick succession), the overhead in file > system function calls makes me feel uneasy when the function could be > called many times a second if arrays of date/time values are being > converted to or from the local time zone. Ah, so that's why the class does such awful amount of unnecessary I/O? Note that this does not only affect runtime but also KDE startup (since the I/O cannot be cached at that time, kernel has pretty bad performance when it comes to many small files and of course everybody has the clock applet). Just strace -f startkde to see. I'd first suggest rethinking the design. Say, a kded module (with the right kded startup phase, see kdebase/ksmserver/README) that does whatever initial checks needed, saves the current timezone to some config file and KTimeZone uses only that. Next startup the module only checks if there have been any changes and does nothing if not. Checking for changes while KDE is running can be done using a file watch. > Plainly, the system time zone is not going to change frequently, so I think > that it would be better to cache it and only reread it periodically. I > propose to set a timer to refresh it once a minute. Any > comments/objections? > > Note that this caching applies to the time *zone* (e.g. "Europe/Paris"). It > has no impact on the handling of daylight saving time shifts which will > still be handled without any time lag. -- Lubos Lunak KDE developer -------------------------------------------------------------- SUSE LINUX, s.r.o. e-mail: l.lunak@suse.cz , l.lunak@kde.org Lihovarska 1060/12 tel: +420 284 028 972 190 00 Prague 9 fax: +420 284 028 951 Czech Republic http//www.suse.cz