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:
Sean Rhea
2009-10-25 17:16:49 -04:00
parent 0d45c46a2a
commit d3b1a62af3

View File

@@ -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);