Opened 18 years ago

Closed 17 years ago

#560 closed enhancement (invalid)

Decrease mythweather load-up time significantly

Reported by: mythtv@… Owned by: ldunning
Priority: minor Milestone: unknown
Component: mythweather Version: head
Severity: medium Keywords: mythweatherupdate
Cc: Ticket locked: no

Description

Currently, weather information is downloaded on demand. This makes the start-up time quite expansive (about 8 seconds on my machine).

This "patch" (more on that later) creates a new program: mythweatherupdate that downloads the weather data and stores it in GetConfDir?()/MythWeather?. Mythweather, instead of needing to download the data when starting-up, can utilize the cache when it exists. This decreases the load time for weather data from 5-10 seconds under a second. Backwards compatability is maintained (that is, if mythweatherupdate is not periodically run, weather data will still be displayed).

Details

A new class, WeatherData?, was created to hold the weather data. This allows mythweatherupdate to access the data without needing to create a Weather object, which would attempt to create UI objects.

Backward compatability is maintained. If mythweatherupdate is not periodically run, for whatever reason, mythweather caches the weather data it downloads. If the cache is less than 90 minutes old, it will be reused. Otherwise, the data is downloaded and the cache refreshed. 90 minutes was chosen for compatibility with hourly updates.

Another change is that the animated radar image is created lazily. That is, it is not created until the page changes to AnimatedImage?->GetContext?(). The creation of this image takes a noticable amount of time on my machine (~0.7 seconds), making the load time significantly longer. If you passively watch mythweather, this time is difficult to notice (it stays on the screen before the radar image slightly longer), but it can be noticable if you use left/right to change screen. In any case, you now pay the lag only if you have to.

Because this is such a major rewrite, the "patch" is actually a tar ball of all the source code. Changes to mythweather through patch set 7527 (currently, the last change) are included.

Caveats

This is a relatively large rewrite of mythweather. Although little code in the mythweather proper changed, it has been reshuffled and one class between two classes. I tried to be conservative in changing things, which has some consequences (one of which is that, unfortunately, resulted in Weather and WeatherData? being friends).

For cleanness, mythweatherupdate is dynamically linked against libmythweather.so. This means that it must be invoked with the plugin directory in LD_LIBRARY_PATH (LD_LIBRARY_PATH=/usr/local/lib/mythtv/plugins mythweatherupdate). The old way was to recompile the source files in mythweather directly into mythweatherupdate. It would be easy to change this back, but I was not happy with that. The other alternative would be to soft link to libmythweather.so from $PREFIX/lib. Not difficult to change. Uncertain which would be most appealing to the maintainers (they may have a better idea that those), I left it as this, which is easy to change to either of the other two options.

Conclusions

This enhancement "patch" makes mythweather almost instataneous to access, enabling one to quickly check the weather.

(Sorry for the long ticket)

Attachments (1)

weatherupdate-1.tar.gz (17.0 KB) - added by mythtv@… 18 years ago.
MythWeatherUpdate? code

Download all attachments as: .zip

Change History (8)

Changed 18 years ago by mythtv@…

Attachment: weatherupdate-1.tar.gz added

comment:1 Changed 18 years ago by mythtv@…

Summary: Increase mythweather load-up time significantlyDecrease mythweather load-up time significantly

Increasing the load-up time would NOT be an improvement. Oops.

comment:2 Changed 18 years ago by Nigel

Caching the information in the filesystem is good, but I think it does one copy on each frontend machine? (Haven't unrolled and checked the code yet. Sorry)

What do we think about caching this in the database instead? (although, the radar images are maybe too large for that)

comment:3 Changed 18 years ago by paulh

Milestone: 0.20

I've been using my own hacked up version of mythweather for many months now. I took a slightly different approach to the problem. I put the data downloading in its own thread and ditched the very slow weather.com for another data source. As it stands it would be difficult to use what I have now and make it work for everybody though.

What would be great is to enhance what you have wrote to allow for different data sources. It would have to allow for the fact that different sources may have different amounts of weather data available. MythWeather? would become a dumb frontend to the weather grabbers that just displays the pages of information given to it by the grabber. All of the intelligence would be in the grabbers which could all have there own ui.xml files to display the weather data available to it.

comment:4 Changed 18 years ago by Isaac Richards

Owner: changed from Isaac Richards to paulh

comment:5 Changed 18 years ago by cpinkham

Milestone: 0.20unknown

Doubt this will go in before 0.20 and the future is uncertain because of the MythWeather? SoC project. Marking as 'unknown' for now.

comment:6 Changed 18 years ago by Isaac Richards

Owner: changed from paulh to ldunning

comment:7 Changed 17 years ago by greg

Resolution: invalid
Status: newclosed

With the import of the new mythweather branch into trunk this ticket is no longer valid

Note: See TracTickets for help on using tickets.