Commit abdc13eb authored by Matthieu Muffato's avatar Matthieu Muffato
Browse files

Added a mode to plot the amount of wasted memory by each analysis

parent 85cd35e0
......@@ -71,6 +71,7 @@ sub main {
workers => 'Number of workers',
memory => 'Memory asked (Gb)',
cores => 'Number of CPU cores',
wasted_memory => 'Wasted memory (Gb)',
);
if ($mode) {
die "Unknown mode '$mode'. Allowed modes are: ".join(", ", keys %allowed_modes) unless exists $allowed_modes{$mode};
......@@ -116,6 +117,19 @@ sub main {
}
}
}
warn "mem_resources: ", Dumper \%mem_resources;
warn "cpu_resources: ", Dumper \%cpu_resources;
# Get the memory used by each worker
my %used_mem = ();
if ($mode eq 'wasted_memory') {
my $sql_used_mem = 'SELECT meadow_name, process_id, mem_megs FROM lsf_report';
foreach my $db_entry (@{$dbh->selectall_arrayref($sql_used_mem)}) {
my ($meadow_name, $process_id, $mem_megs) = @$db_entry;
$used_mem{$meadow_name."_____".$process_id} = $mem_megs;
}
warn scalar(keys %used_mem), " process info loaded from lsf_report\n";
}
# Get the info about the analysis
my %default_resource_class = ();
......@@ -135,19 +149,25 @@ sub main {
# Get the events from the database
my %events = ();
{
my @tmp_dates = @{$dbh->selectall_arrayref('SELECT DATE_FORMAT(born, "%Y-%m-%dT%T"), analysis_id, resource_class_id, 1 FROM worker WHERE analysis_id IS NOT NULL')};
push @tmp_dates, @{$dbh->selectall_arrayref('SELECT DATE_FORMAT(died, "%Y-%m-%dT%T"), analysis_id, resource_class_id, -1 FROM worker WHERE analysis_id IS NOT NULL')};
my @tmp_dates = @{$dbh->selectall_arrayref('SELECT DATE_FORMAT(born, "%Y-%m-%dT%T"), analysis_id, meadow_name, process_id, resource_class_id, 1 FROM worker WHERE analysis_id IS NOT NULL')};
push @tmp_dates, @{$dbh->selectall_arrayref('SELECT DATE_FORMAT(died, "%Y-%m-%dT%T"), analysis_id, meadow_name, process_id, resource_class_id, -1 FROM worker WHERE analysis_id IS NOT NULL')};
warn scalar(@tmp_dates), " events\n";
foreach my $db_entry (@tmp_dates) {
my ($event_date, $analysis_id, $resource_class_id, $offset) = @$db_entry;
my ($event_date, $analysis_id, $meadow_name, $process_id, $resource_class_id, $offset) = @$db_entry;
$resource_class_id = $default_resource_class{$analysis_id} unless $resource_class_id;
if ($mode eq 'workers') {
$events{$event_date}{$analysis_id} += $offset;
} elsif ($mode eq 'memory') {
$events{$event_date}{$analysis_id} += $offset * ($mem_resources{$resource_class_id} || $default_memory) / 1024.;
} else {
} elsif ($mode eq 'cores') {
$events{$event_date}{$analysis_id} += $offset * ($cpu_resources{$resource_class_id} || $default_cores);
} else {
my $process_signature = $meadow_name."_____".$process_id;
if (exists $used_mem{$process_signature}) {
my $wasted_memory = ($mem_resources{$resource_class_id} || $default_memory) - $used_mem{$process_signature};
$events{$event_date}{$analysis_id} += $offset * $wasted_memory / 1024. if $wasted_memory > 0;
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment