mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 08:08:42 +00:00
reduce memory footprint of StressCalculator
After processing each RideItem, call freeMemory to deallocate the RideFile object inside it, since we're done with the RideFile once we have the BikeScore. Also call computeMetrics instead of htmlSummary, since we only need the BikeScore and computeMetrics is faster. After computing the stress cache from scratch on Sean's ride library (3 years of rides), this change reduces the process virtual memory size (VSIZE) from 769 MB to 412 MB. Even more dramatically, it reduces the resident set size (RSIZE) from 389 MB to 36 MB! On Sean's MacBook, which has 4 GB of RAM, this change results in a modest reduction in the time to compute the stress cache, from 17 seconds down to 14. On machines with more limited memory footprints, or when dealing with a larger ride library, the speedup could be very dramatic. (Once the process starts paging, it's going to crawl.) Now that it only takes 14 seconds to calculate, it's really not clear to me that we need store the stress cache on the filesystem at all.
This commit is contained in:
@@ -121,13 +121,15 @@ void StressCalculator::calculateStress(QWidget *mw,
|
||||
bs = cache[ridedatestring];
|
||||
}
|
||||
else {
|
||||
item->htmlSummary(); // compute metrics
|
||||
item->computeMetrics();
|
||||
|
||||
if ((m = item->metrics.value("skiba_bike_score")) &&
|
||||
m->value(true)) {
|
||||
bs = m->value(true);
|
||||
}
|
||||
cache[ridedatestring] = bs;
|
||||
|
||||
item->freeMemory();
|
||||
}
|
||||
|
||||
addRideData(bs,item->dateTime);
|
||||
|
||||
Reference in New Issue
Block a user