mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-66234 analytics: Extra GC during analysis
This commit is contained in:
parent
f622ee97e3
commit
c430def90d
@ -59,6 +59,9 @@ class predict_models extends \core\task\scheduled_task {
|
||||
}
|
||||
|
||||
foreach ($models as $model) {
|
||||
|
||||
$renderer = $PAGE->get_renderer('tool_analytics');
|
||||
|
||||
$result = $model->predict();
|
||||
|
||||
// Reset the page as some indicators may call external functions that overwrite the page context.
|
||||
@ -66,7 +69,6 @@ class predict_models extends \core\task\scheduled_task {
|
||||
|
||||
if ($result) {
|
||||
echo $OUTPUT->heading(get_string('modelresults', 'tool_analytics', $model->get_name()));
|
||||
$renderer = $PAGE->get_renderer('tool_analytics');
|
||||
echo $renderer->render_get_predictions_results(false, array(), $result, $model->get_analyser()->get_logs());
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,8 @@ class train_models extends \core\task\scheduled_task {
|
||||
continue;
|
||||
}
|
||||
|
||||
$renderer = $PAGE->get_renderer('tool_analytics');
|
||||
|
||||
$result = $model->train();
|
||||
|
||||
// Reset the page as some indicators may call external functions that overwrite the page context.
|
||||
@ -77,8 +79,6 @@ class train_models extends \core\task\scheduled_task {
|
||||
|
||||
if ($result) {
|
||||
echo $OUTPUT->heading(get_string('modelresults', 'tool_analytics', $model->get_name()));
|
||||
|
||||
$renderer = $PAGE->get_renderer('tool_analytics');
|
||||
echo $renderer->render_get_predictions_results($result, $model->get_analyser()->get_logs());
|
||||
}
|
||||
}
|
||||
|
@ -102,6 +102,8 @@ if ($options['reuse-prev-analysed']) {
|
||||
mtrace(get_string('evaluationinbatches', 'tool_analytics'));
|
||||
}
|
||||
|
||||
$renderer = $PAGE->get_renderer('tool_analytics');
|
||||
|
||||
$analyseroptions = array(
|
||||
'filter' => $options['filter'],
|
||||
'timesplitting' => $options['analysisinterval'],
|
||||
@ -114,7 +116,6 @@ $results = $model->evaluate($analyseroptions);
|
||||
// Reset the page as some indicators may call external functions that overwrite the page context.
|
||||
\tool_analytics\output\helper::reset_page();
|
||||
|
||||
$renderer = $PAGE->get_renderer('tool_analytics');
|
||||
echo $renderer->render_evaluate_results($results, $model->get_analyser()->get_logs());
|
||||
|
||||
// Check that we have, at leasa,t 1 valid dataset (not necessarily good) to use.
|
||||
|
@ -138,6 +138,9 @@ class analysis {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Force GC to clean up the indicator instances used during the last iteration.
|
||||
$this->analyser->instantiate_indicators();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -474,6 +477,11 @@ class analysis {
|
||||
list($samplesfeatures, $newindicatorcalculations, $indicatornotnulls) = $rangeindicator->calculate($sampleids,
|
||||
$this->analyser->get_samples_origin(), $range['start'], $range['end'], $prevcalculations);
|
||||
|
||||
// Free memory ASAP.
|
||||
unset($rangeindicator);
|
||||
gc_collect_cycles();
|
||||
gc_mem_caches();
|
||||
|
||||
// Copy the features data to the dataset.
|
||||
foreach ($samplesfeatures as $analysersampleid => $features) {
|
||||
|
||||
@ -503,7 +511,7 @@ class analysis {
|
||||
$indcalc->endtime = $range['end'];
|
||||
$indcalc->sampleid = $sampleid;
|
||||
$indcalc->sampleorigin = $this->analyser->get_samples_origin();
|
||||
$indcalc->indicator = $rangeindicator->get_id();
|
||||
$indcalc->indicator = $indicator->get_id();
|
||||
$indcalc->value = $calculatedvalue;
|
||||
$indcalc->timecreated = $timecreated;
|
||||
$newcalculations[] = $indcalc;
|
||||
|
@ -246,6 +246,11 @@ abstract class base {
|
||||
foreach ($this->indicators as $key => $indicator) {
|
||||
$this->indicators[$key] = call_user_func(array($indicator, 'instance'));
|
||||
}
|
||||
|
||||
// Free memory ASAP.
|
||||
gc_collect_cycles();
|
||||
gc_mem_caches();
|
||||
|
||||
return $this->indicators;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user