Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAPL energy filtering moved to provider #979

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions lib/system_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import subprocess
import psutil
import locale
import platform

from psycopg import OperationalError as psycopg_OperationalError

Expand Down Expand Up @@ -57,18 +56,6 @@ def check_free_disk():
def check_free_memory():
return psutil.virtual_memory().available >= GMT_Resources['free_memory']

def check_energy_filtering():
if platform.system() != 'Linux':
print(TerminalColors.WARNING, '>>>> RAPL could not be checked as not running on Linux platform <<<<', TerminalColors.ENDC)
return True

result = subprocess.run(['sudo', 'python3', '-m', 'lib.hardware_info_root', '--read-rapl-energy-filtering'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=os.path.abspath(os.path.join(CURRENT_DIR, '..')),
check=True, encoding='UTF-8')
return "1" != result.stdout.strip()

def check_containers_running():
result = subprocess.run(['docker', 'ps', '--format', '{{.Names}}'],
stdout=subprocess.PIPE,
Expand Down Expand Up @@ -98,7 +85,6 @@ def check_utf_encoding():
(check_docker_daemon, Status.ERROR, 'docker daemon', 'The docker daemon could not be reached. Are you running in rootless mode or have added yourself to the docker group? See installation: [See https://docs.green-coding.io/docs/installation/]'),
(check_containers_running, Status.WARN, 'running containers', 'You have other containers running on the system. This is usually what you want in local development, but for undisturbed measurements consider going for a measurement cluster [See https://docs.green-coding.io/docs/installation/installation-cluster/].'),
(check_utf_encoding, Status.ERROR, 'utf file encoding', 'Your system encoding is not set to utf-8. This is needed as we need to parse console output.'),
(check_energy_filtering, Status.ERROR, 'rapl energy filtering', 'RAPL Energy filtering is active!'),
]

def check_start():
Expand Down
11 changes: 11 additions & 0 deletions lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from lib import error_helpers
from lib.db import DB

CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))

def get_git_api(parsed_url):

if parsed_url.netloc in ['github.com', 'www.github.com']:
Expand Down Expand Up @@ -168,3 +170,12 @@ def get_architecture():
if output == 'darwin':
return 'macos'
return output


def is_rapl_energy_filtering_deactivated():
result = subprocess.run(['sudo', 'python3', '-m', 'lib.hardware_info_root', '--read-rapl-energy-filtering'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=os.path.abspath(os.path.join(CURRENT_DIR, '..')),
check=True, encoding='UTF-8')
return '1' != result.stdout.strip()
8 changes: 7 additions & 1 deletion metric_providers/cpu/energy/rapl/msr/component/provider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from metric_providers.base import BaseMetricProvider
from metric_providers.base import BaseMetricProvider, MetricProviderConfigurationError
from lib.utils import is_rapl_energy_filtering_deactivated

class CpuEnergyRaplMsrComponentProvider(BaseMetricProvider):
def __init__(self, resolution, skip_check=False):
Expand All @@ -13,6 +14,11 @@ def __init__(self, resolution, skip_check=False):
skip_check=skip_check,
)

def check_system(self, check_command="default", check_error_message=None, check_parallel_provider=True):
super().check_system()
if not is_rapl_energy_filtering_deactivated():
raise MetricProviderConfigurationError('RAPL energy filtering is active and might skew results!')

def read_metrics(self, run_id, containers=None):
df = super().read_metrics(run_id, containers)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from metric_providers.base import BaseMetricProvider
from metric_providers.base import BaseMetricProvider, MetricProviderConfigurationError
from lib.utils import is_rapl_energy_filtering_deactivated

class MemoryEnergyRaplMsrComponentProvider(BaseMetricProvider):
def __init__(self, resolution, skip_check=False):
Expand All @@ -18,6 +19,9 @@ def check_system(self, check_command="default", check_error_message=None, check_
call_string = f"{self._current_dir}/{self._metric_provider_executable}"
super().check_system(check_command=[f"{call_string}", '-c', '-d'])

if not is_rapl_energy_filtering_deactivated():
raise MetricProviderConfigurationError('RAPL energy filtering is active and might skew results!')

def read_metrics(self, run_id, containers=None):
df = super().read_metrics(run_id, containers)

Expand Down
6 changes: 5 additions & 1 deletion metric_providers/psu/energy/dc/rapl/msr/machine/provider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from metric_providers.base import BaseMetricProvider
from metric_providers.base import BaseMetricProvider, MetricProviderConfigurationError
from lib.utils import is_rapl_energy_filtering_deactivated

class PsuEnergyDcRaplMsrMachineProvider(BaseMetricProvider):
def __init__(self, resolution, skip_check=False):
Expand All @@ -18,6 +19,9 @@ def check_system(self, check_command="default", check_error_message=None, check_
call_string = f"{self._current_dir}/{self._metric_provider_executable}"
super().check_system(check_command=[f"{call_string}", '-c', '-p'])

if not is_rapl_energy_filtering_deactivated():
raise MetricProviderConfigurationError('RAPL energy filtering is active and might skew results!')


def read_metrics(self, run_id, containers=None):
df = super().read_metrics(run_id, containers)
Expand Down