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

Implements experiments to run and time traced and untraced versions of all binaries in a project #588

Open
wants to merge 46 commits into
base: vara-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
928308e
Small refactoring for fm provider
vulder Nov 23, 2021
3a70322
Adds project for FeaturePerfCS repo
vulder Nov 23, 2021
724d158
Cleans up compiler handling for lrzip
vulder Nov 23, 2021
aa39871
Adds initial draft of feature perf runner
vulder Nov 23, 2021
9ff98d2
Adds exception should a FM not be found
vulder Nov 23, 2021
7394108
Implements core report discovery
vulder Nov 24, 2021
7e87e2a
Small clean up
vulder Nov 24, 2021
2115e2b
Implements report for trace event format
vulder Nov 24, 2021
60471b0
Merge branch 'vara-dev' into f-FeaturePerfMeasure
vulder Dec 26, 2021
9ff38ae
Ensure type conversions from json
vulder Dec 26, 2021
a150bc5
Add doc string and desc to exec step
vulder Dec 26, 2021
4bf78a2
Fixes type error
vulder Dec 26, 2021
704fd53
premerge
niomate Jan 19, 2022
761f5dc
resolve merge conflicts
niomate Jan 19, 2022
004b7ef
Adapts variant calculation to be experiment specific
vulder Jan 19, 2022
9213d3f
Ports code to consider all reports not just the main report
vulder Jan 19, 2022
042ab2e
Removes error check
vulder Jan 19, 2022
4f63fe5
Merge branch 'vara-dev' into f-FixVariantRedLookup
vulder Jan 20, 2022
b79167d
Merge remote-tracking branch 'origin/f-FixVariantRedLookup' into ma-g…
niomate Jan 20, 2022
851556f
Merge branch 'vara-dev' into ma-gusenburger
niomate Jan 20, 2022
56060eb
first naive implementation of RunTraced and RunUntraced experiments
niomate Jan 21, 2022
a8e0440
implemented common base class for evaluation experiments
niomate Jan 24, 2022
1a547e4
Merge branch 'vara-dev' into ma-gusenburger
vulder Feb 2, 2022
fa125a1
implemented some of the suggested changes
niomate Feb 8, 2022
146c8a8
Merge branch 'ma-gusenburger' of github.com:se-passau/VaRA-Tool-Suite…
niomate Feb 8, 2022
87b2c13
Merge remote-tracking branch 'origin/vara-dev' into ma-gusenburger
niomate Mar 2, 2022
375a0a9
fix: now passing correct CLI args to clang in RunTimeTraced to proper…
niomate Apr 11, 2022
1be8aa0
merged with dev branch
niomate Apr 11, 2022
e5e9b05
Merge branch 'vara-dev' into ma-gusenburger
niomate Apr 15, 2022
2858825
fix: removed type ignore comments
niomate Apr 15, 2022
1d45644
merged vara-dev into branch
niomate Jan 5, 2023
1a2728a
Merge remote-tracking branch 'origin/vara-dev' into ma-gusenburger
niomate Jan 17, 2023
ed9a39c
updated experiments
niomate Jan 20, 2023
8a5cea5
Merge remote-tracking branch 'origin/vara-dev' into ma-gusenburger
niomate Jan 20, 2023
125970a
added workloads to bzip2 and lrzip, rewrote instrumentation stats to …
niomate Apr 10, 2023
4f018c1
added dynamic overhead analysis (WIP)
niomate Apr 10, 2023
adce0dd
merged with vara-dev
niomate Apr 10, 2023
9b3d995
implemented multicompileexperiment
niomate May 4, 2023
9982927
added multiple budget experiment to instrumentation verifier
niomate May 16, 2023
ff9a904
reverse compability to python 3.9.x
May 17, 2023
11cb37c
separated implementations for RunTraced for VaryingBudget and regular…
niomate May 18, 2023
a729e2b
InstrVerifierReport should not produce useful results for experiments…
niomate Jun 9, 2023
68aa7d7
updating
niomate Oct 5, 2023
9bba9c4
resolved merge conflicts
niomate Oct 5, 2023
b0113aa
updates
niomate Oct 9, 2023
5f07720
final commit
niomate Oct 16, 2023
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
1 change: 1 addition & 0 deletions varats-core/varats/experiment/experiment_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from collections import defaultdict
from pathlib import Path
from types import TracebackType
import yaml

from benchbuild import source
from benchbuild.experiment import Experiment
Expand Down
4 changes: 1 addition & 3 deletions varats-core/varats/report/gnu_time_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ def __init__(self, path: Path) -> None:
TimeReport._parse_involuntary_ctx_switches(line)
continue

# print("Not matched: ", line)

@property
def command_name(self) -> str:
"""Name of the command that was executed."""
Expand Down Expand Up @@ -284,7 +282,7 @@ def summary(self) -> str:

class WLTimeReportAggregate(
WorkloadSpecificReportAggregate[TimeReport],
shorthand=TimeReport.SHORTHAND + ReportAggregate.SHORTHAND,
shorthand="WL" + TimeReport.SHORTHAND + ReportAggregate.SHORTHAND,
file_type=ReportAggregate.FILE_TYPE
):
"""Context Manager for parsing multiple time reports stored inside a zip
Expand Down
1 change: 0 additions & 1 deletion varats-core/varats/report/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,6 @@ def is_correct_report_type(cls, file_name: str) -> bool:
except ValueError:
return False


class ReportSpecification():
"""Groups together multiple report types into a specification that can be
used, e.g., by experiments, to request multiple reports."""
Expand Down
38 changes: 17 additions & 21 deletions varats-core/varats/report/tef_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ class TraceEventType(Enum):

value: str # pylint: disable=invalid-name

DURATION_EVENT_BEGIN = 'B'
DURATION_EVENT_END = 'E'
COMPLETE_EVENT = 'X'
INSTANT_EVENT = 'i'
COUNTER_EVENT = 'C'
ASYNC_EVENT_START = 'b'
ASYNC_EVENT_INSTANT = 'n'
ASYNC_EVENT_END = 'e'
FLOW_EVENT_START = 's'
FLOW_EVENT_STEP = 't'
FLOW_EVENT_END = 'f'
SAMPLE_EVENT = 'P'
DURATION_EVENT_BEGIN = "B"
DURATION_EVENT_END = "E"
COMPLETE_EVENT = "X"
INSTANT_EVENT = "i"
COUNTER_EVENT = "C"
ASYNC_EVENT_START = "b"
ASYNC_EVENT_INSTANT = "n"
ASYNC_EVENT_END = "e"
FLOW_EVENT_START = "s"
FLOW_EVENT_STEP = "t"
FLOW_EVENT_END = "f"
SAMPLE_EVENT = "P"

@staticmethod
def parse_event_type(raw_event_type: str) -> 'TraceEventType':
def parse_event_type(raw_event_type: str) -> "TraceEventType":
"""Parses a raw string that represents a trace-format event type and
converts it to the corresponding enum value."""
for trace_event_type in TraceEventType:
Expand All @@ -45,7 +45,7 @@ def __str__(self) -> str:
return str(self.value)


class TraceEvent():
class TraceEvent:
"""Represents a trace event that was captured during the analysis of a
target program."""

Expand All @@ -56,9 +56,7 @@ def __init__(
self.__name_id_mapper = name_id_mapper
self.__name_id = name_id
self.__category = str(json_trace_event["cat"])
self.__event_type = TraceEventType.parse_event_type(
json_trace_event["ph"]
)
self.__event_type = TraceEventType.parse_event_type(json_trace_event["ph"])
self.__tracing_clock_timestamp = int(json_trace_event["ts"])
self.__pid = int(json_trace_event["pid"])
self.__tid = int(json_trace_event["tid"])
Expand Down Expand Up @@ -128,9 +126,7 @@ def trace_events(self) -> tp.List[TraceEvent]:

@property
def stack_frames(self) -> None:
raise NotImplementedError(
"Stack frame parsing is currently not implemented!"
)
raise NotImplementedError("Stack frame parsing is currently not implemented!")

def _parse_json(self) -> None:
trace_events: tp.List[TraceEvent] = list()
Expand Down Expand Up @@ -172,7 +168,7 @@ def _parse_json(self) -> None:
class TEFReportAggregate(
ReportAggregate[TEFReport],
shorthand=TEFReport.SHORTHAND + ReportAggregate.SHORTHAND,
file_type=ReportAggregate.FILE_TYPE
file_type=ReportAggregate.FILE_TYPE,
):
"""Context Manager for parsing multiple TEF reports stored inside a zip
file."""
Expand Down
53 changes: 53 additions & 0 deletions varats/varats/data/reports/dynamic_overhead_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from varats.report.report import BaseReport
from pathlib import Path
from collections import defaultdict


class DynamicOverheadReport(
BaseReport, shorthand="DynOverhead", file_type="txt"
):

class RegionCounter:

def __init__(self):
self.__in = 0
self.__out = 0

def enter(self):
self.__in += 1

def leave(self):
self.__out += 1

def isvalid(self):
return self.__in == self.__out

def count_visited(self):
return self.__in

def __init__(self, path: Path):
super().__init__(path)
self.__entries = defaultdict(DynamicOverheadReport.RegionCounter)

for line in open(path, "r"):
try:
command, id = line.split()
if command == "Entering":
self.__entries[id].enter()
elif command == "Leaving":
self.__entries[id].leave()
except ValueError:
continue

self.__total_region_count = 0

# Generate report
for region in self.__entries.values():
if region.isvalid():
self.__total_region_count += region.count_visited()

def isvalid(self) -> bool:
return all(v.isvalid() for v in self.__entries.values())

def regions_visited(self):
return self.__total_region_count
16 changes: 14 additions & 2 deletions varats/varats/data/reports/instrumentation_verifier_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import typing as tp
from pathlib import Path
from zipfile import ZipFile
import yaml

from varats.report.report import BaseReport

Expand All @@ -15,10 +16,15 @@ def __init__(self, report_path: Path) -> None:
super().__init__(report_path)

self.__report_data = {}
self.__metadata = {}

with ZipFile(report_path, "r") as archive:

for file in archive.namelist():
if file == "metadata.yml":
with archive.open(file, "r") as f:
self.__metadata = yaml.load(f, yaml.Loader)

if not file.endswith(".ivr"):
continue

Expand Down Expand Up @@ -58,7 +64,9 @@ def __init__(self, report_path: Path) -> None:
unclosed_enter_begin = content.index(
'Unclosed Region-ID(s):'
) + 1
wrong_leaves = content[wrong_leaves_begin:-1]
failure_begin = content.index("Finalization: Failure")
wrong_leaves = content[
wrong_leaves_begin:failure_begin - 1]
unclosed_regions = content[
unclosed_enter_begin:wrong_leaves_begin - 1]

Expand Down Expand Up @@ -137,9 +145,13 @@ def num_unentered_leaves(self, binary: str) -> int:

def states(self) -> tp.Dict[str, str]:
return {
binary: data['state'] # type: ignore
binary:
data['state'] # type: ignore
for binary, data in self.__report_data.items()
}

def state(self, binary: str) -> str:
return self.__report_data[binary]['state'] # type: ignore

def metadata(self) -> tp.Dict[tp.Any, tp.Any]:
return self.__metadata
25 changes: 22 additions & 3 deletions varats/varats/experiments/base/time_workloads.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Implements an experiment that times the execution of all project binaries."""

import typing as tp
import textwrap
from pathlib import Path

from benchbuild import Project
Expand Down Expand Up @@ -37,11 +38,16 @@ class TimeProjectWorkloads(OutputFolderStep):
project: VProject

def __init__(
self, project: Project, num: int, binary: ProjectBinaryWrapper
self,
project: Project,
num: int,
binary: ProjectBinaryWrapper,
categories: tp.List[WorkloadCategory] = [WorkloadCategory.EXAMPLE]
):
super().__init__(project=project)
self.__num = num
self.__binary = binary
self.__workload_categories = categories

def call_with_output_folder(self, tmp_dir: Path) -> actions.StepResult:
return self.analyze(tmp_dir)
Expand All @@ -50,9 +56,11 @@ def analyze(self, tmp_dir: Path) -> actions.StepResult:
"""Only create a report file."""

with local.cwd(self.project.builddir):
print(f"Step {self.__num}")
for prj_command in workload_commands(
self.project, self.__binary, [WorkloadCategory.EXAMPLE]
self.project, self.__binary, self.__workload_categories
):
print("Running workload")
pb_cmd = prj_command.command.as_plumbum(project=self.project)

run_report_name = tmp_dir / create_workload_specific_filename(
Expand All @@ -61,11 +69,21 @@ def analyze(self, tmp_dir: Path) -> actions.StepResult:

run_cmd = time['-v', '-o', f'{run_report_name}', pb_cmd]

print("\t", run_cmd)

with cleanup(prj_command):
run_cmd()
run_cmd(retcode=self.__binary.valid_exit_codes)

print("Done")

return actions.StepResult.OK

def __str__(self, indent: int = 0) -> str:
return textwrap.indent(
f"* Run workloads of categories {', '.join(str(x) for x in self.__workload_categories)} "
f"for binary {self.__binary.name} ({self.__num})", indent * " "
)


class TimeWorkloads(VersionExperiment, shorthand="TWL"):
"""Generates time report files."""
Expand Down Expand Up @@ -95,6 +113,7 @@ def actions_for_project(
binary = project.binaries[0]

measurement_repetitions = 2

result_filepath = create_new_success_result_filepath(
self.get_handle(),
self.get_handle().report_spec().main_report, project, binary
Expand Down
Loading