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

bcc, ompi and crun are added #885

Open
wants to merge 6 commits into
base: vara-dev
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions varats-core/varats/project/project_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class ProjectDomains(Enum):
UNIX_TOOLS = "UNIX utils"
VERSION_CONTROL = "Version control"
WEB_TOOLS = "Web tools"
RUNTIME = "Runtime"
MPI = "Message Passing Interface"

def __str__(self) -> str:
return str(self.value)
Expand Down
142 changes: 138 additions & 4 deletions varats/varats/plots/blame_interaction_graph_plots.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Module for BlameInteractionGraph plots."""

import configparser
import subprocess
import typing as tp
from datetime import datetime
from pathlib import Path
Expand All @@ -9,6 +10,7 @@
import networkx as nx
import pandas as pd
import plotly.offline as offply
import pygit2

from varats.data.reports.blame_interaction_graph import (
create_blame_interaction_graph,
Expand All @@ -18,7 +20,7 @@
CAIGNodeAttrs,
)
from varats.experiments.vara.blame_report_experiment import (
BlameReportExperiment,
BlameReportExperiment, BlameReportExperimentRegion,
)
from varats.mapping.commit_map import get_commit_map
from varats.paper_mgmt.case_study import (
Expand Down Expand Up @@ -64,7 +66,7 @@
revision = commit_map.convert_to_full_or_warn(short_revision)

cig = create_blame_interaction_graph(
project_name, revision, BlameReportExperiment
project_name, revision, BlameReportExperimentRegion
).commit_interaction_graph()
nx.set_node_attributes(
cig,
Expand Down Expand Up @@ -109,7 +111,7 @@
NodeTy, NodeTy, EdgeInfoTy]]]:
commit_lookup = create_commit_lookup_helper(project_name)
cig = create_blame_interaction_graph(
project_name, revision, BlameReportExperiment
project_name, revision, BlameReportExperimentRegion
).commit_interaction_graph()

def filter_nodes(node: CommitRepoPair) -> bool:
Expand Down Expand Up @@ -280,6 +282,138 @@
)


def get_gitmodules_info():

Check failure on line 285 in varats/varats/plots/blame_interaction_graph_plots.py

View workflow job for this annotation

GitHub Actions / reviewdog

[mypy] reported by reviewdog 🐶 error: Function is missing a return type annotation [no-untyped-def] Raw Output: varats/varats/plots/blame_interaction_graph_plots.py:285:1: error: Function is missing a return type annotation [no-untyped-def]
repo = pygit2.Repository(REPO_PATH)

Check failure on line 286 in varats/varats/plots/blame_interaction_graph_plots.py

View workflow job for this annotation

GitHub Actions / reviewdog

[mypy] reported by reviewdog 🐶 error: Name "REPO_PATH" is not defined [name-defined] Raw Output: varats/varats/plots/blame_interaction_graph_plots.py:286:30: error: Name "REPO_PATH" is not defined [name-defined]
# Get the .gitmodules blob object
commit = repo[repo.head.target]
tree = commit.tree
gitmodules_entry = tree[".gitmodules"]
gitmodules_blob = repo[gitmodules_entry.oid]

# Parse the .gitmodules file contents
gitmodules_data = gitmodules_blob.data
gitmodules_config = configparser.ConfigParser()
gitmodules_config.read_string(gitmodules_data.decode('utf-8'))

# Collect the submodule path and URL information
submodules = []
for section in gitmodules_config.sections():
if section.startswith('submodule '):
submodule_name = section[len('submodule '):]
submodule_path = gitmodules_config.get(section, 'path')
submodule_url = gitmodules_config.get(section, 'url')
submodules.append((submodule_name, submodule_path, submodule_url))

return submodules


def pull_commit_history_information(submodules):

Check failure on line 310 in varats/varats/plots/blame_interaction_graph_plots.py

View workflow job for this annotation

GitHub Actions / reviewdog

[mypy] reported by reviewdog 🐶 error: Function is missing a type annotation [no-untyped-def] Raw Output: varats/varats/plots/blame_interaction_graph_plots.py:310:1: error: Function is missing a type annotation [no-untyped-def]

# Get the tree object for the specified commit
repo = pygit2.Repository(REPO_PATH)

Check failure on line 313 in varats/varats/plots/blame_interaction_graph_plots.py

View workflow job for this annotation

GitHub Actions / reviewdog

[mypy] reported by reviewdog 🐶 error: Name "REPO_PATH" is not defined [name-defined] Raw Output: varats/varats/plots/blame_interaction_graph_plots.py:313:30: error: Name "REPO_PATH" is not defined [name-defined]

commits = []
i = 0
for submodule in submodules:
walker = repo.walk(repo.head.target, pygit2.GIT_SORT_TOPOLOGICAL | pygit2.GIT_SORT_REVERSE)
subdirectory_path = submodule[1]
for commit in walker:
# Initialize a flag to check if the 'third_party' has changes in this commit
# has_changes = False
# Compare the tree of this commit with its parent
if len(commit.parents) == 0:
continue
diff = repo.diff(commit.parents[0], commit)
# Loop through all patches in the diff
files_changed = [patch.delta.new_file.path for patch in diff]
if any([file.startswith(subdirectory_path) for file in files_changed]):
i += 1
print(i) # total 1864 times commits is for third party
commits.append({
'author_name': commit.author.name,
'author_email': commit.author.email,
# 'message': commit.message,
'commit_hash': commit.hex,
'commit_time': datetime.datetime.fromtimestamp(commit.commit_time)

Check failure on line 337 in varats/varats/plots/blame_interaction_graph_plots.py

View workflow job for this annotation

GitHub Actions / reviewdog

[mypy] reported by reviewdog 🐶 error: "type[datetime]" has no attribute "datetime" [attr-defined] Raw Output: varats/varats/plots/blame_interaction_graph_plots.py:337:36: error: "type[datetime]" has no attribute "datetime" [attr-defined]
# 'changed_folder': get_change_folder(commit)
})

df = pd.DataFrame(commits)
# df.to_csv(TASK_PATH + 'openssl_commit_history2.csv', index=False)

return df


class SubCommitInteractionGraphPlot(Plot, plot_name='sub-cig-plot'):
submodule_info = get_gitmodules_info()

Check failure on line 348 in varats/varats/plots/blame_interaction_graph_plots.py

View workflow job for this annotation

GitHub Actions / reviewdog

[mypy] reported by reviewdog 🐶 error: Call to untyped function "get_gitmodules_info" in typed context [no-untyped-call] Raw Output: varats/varats/plots/blame_interaction_graph_plots.py:348:22: error: Call to untyped function "get_gitmodules_info" in typed context [no-untyped-call]
df = pull_commit_history_information(submodule_info)

Check failure on line 349 in varats/varats/plots/blame_interaction_graph_plots.py

View workflow job for this annotation

GitHub Actions / reviewdog

[mypy] reported by reviewdog 🐶 error: Call to untyped function "pull_commit_history_information" in typed context [no-untyped-call] Raw Output: varats/varats/plots/blame_interaction_graph_plots.py:349:10: error: Call to untyped function "pull_commit_history_information" in typed context [no-untyped-call]

def is_submodule_change(self, commit_hash):

Check failure on line 351 in varats/varats/plots/blame_interaction_graph_plots.py

View workflow job for this annotation

GitHub Actions / reviewdog

[mypy] reported by reviewdog 🐶 error: Function is missing a type annotation [no-untyped-def] Raw Output: varats/varats/plots/blame_interaction_graph_plots.py:351:5: error: Function is missing a type annotation [no-untyped-def]
for index, row in self.df.iterrows():
if row['commit_hash'] == commit_hash:
return True
else:
return False

def plot(self, view_mode: bool) -> None:
project_name = self.plot_kwargs["case_study"].project_name
commit_map = get_commit_map(project_name)
short_revision = ShortCommitHash(self.plot_kwargs["revision"])
revision = commit_map.convert_to_full_or_warn(short_revision)

cig = create_blame_interaction_graph(
project_name, revision, BlameReportExperimentRegion
).commit_interaction_graph()
nx.set_node_attributes(
cig,
{node: cig.nodes[node]["commit"].commit_hash for node in cig.nodes},
"label"
)

# Find nodes representing commits that changed submodules
submodule_commit_nodes = [node for node in cig.nodes if
self.is_submodule_change(cig.nodes[node]["commit"].commit_hash)]

Check failure on line 375 in varats/varats/plots/blame_interaction_graph_plots.py

View workflow job for this annotation

GitHub Actions / reviewdog

[mypy] reported by reviewdog 🐶 error: Call to untyped function "is_submodule_change" in typed context [no-untyped-call] Raw Output: varats/varats/plots/blame_interaction_graph_plots.py:375:35: error: Call to untyped function "is_submodule_change" in typed context [no-untyped-call]

# Count the number of unique authors for main repository and submodule changes
main_repo_authors = set()
submodule_change_authors = set()

for node in cig.nodes:
commit_info = cig.nodes[node]["commit"]
author = commit_info.author_name # Assuming the existence of the author_name attribute, modify as needed

main_repo_authors.add(author)

if node in submodule_commit_nodes:
submodule_change_authors.add(author)

main_repo_author_count = len(main_repo_authors)
submodule_change_author_count = len(submodule_change_authors)

print(f"Main Repository Authors: {main_repo_author_count}")
print(f"Authors with Submodule Changes: {submodule_change_author_count}")



def calc_missing_revisions(
self, boundary_gradient: float
) -> tp.Set[FullCommitHash]:
raise UnsupportedOperation


class SubCIGPlotGenerator(
PlotGenerator,
generator_name="sub-cig-plot",
options=[REQUIRE_CASE_STUDY, REQUIRE_REVISION]
):
"""Generates a plot for a submodule's commit interaction graph."""

def generate(self) -> tp.List[Plot]:
return [
SubCommitInteractionGraphPlot(self.plot_config, **self.plot_kwargs)
]


class CommitInteractionGraphNodeDegreePlot(Plot, plot_name='cig_node_degrees'):
"""
Plot node degrees of a commit interaction graph.
Expand Down
101 changes: 101 additions & 0 deletions varats/varats/projects/c_projects/bcc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
"""Project file for the bcc."""
import typing as tp

import benchbuild as bb
from benchbuild.utils.cmd import make, mkdir, cmake, sudo
from benchbuild.utils.settings import get_number_of_jobs
from plumbum import local

from varats.containers.containers import get_base_image, ImageBase
from varats.paper.paper_config import (
project_filter_generator,
PaperConfigSpecificGit,
)
from varats.project.project_domain import ProjectDomains
from varats.project.project_util import (
ProjectBinaryWrapper,
BinaryType,
verify_binaries,
get_local_project_git_path,
)
from varats.project.varats_project import VProject
from varats.utils.git_util import ShortCommitHash, RevisionBinaryMap
from varats.utils.settings import bb_cfg


class Bcc(VProject):

NAME = 'bcc'
GROUP = 'c_projects'
DOMAIN = ProjectDomains.UNIX_TOOLS

SOURCE = [
PaperConfigSpecificGit(
project_name="bcc",
remote="https://github.com/iovisor/bcc",
local="bcc",
refspec="origin/HEAD",
limit=None,
shallow=False
),
bb.source.GitSubmodule(
remote="https://github.com/libbpf/libbpf.git",
local="bcc/src/cc/libbpf",
refspec="origin/HEAD",
limit=None,
shallow=False,
version_filter=project_filter_generator("bcc")
),
bb.source.GitSubmodule(
remote="https://github.com/libbpf/bpftool",
local="bcc/libbpf-tools/bpftool",
refspec="origin/HEAD",
limit=None,
shallow=False,
version_filter=project_filter_generator("bcc")
),
bb.source.GitSubmodule(
remote="https://github.com/libbpf/blazesym",
local="bcc/ibbpf-tools/blazesym",
refspec="origin/HEAD",
limit=None,
shallow=False,
version_filter=project_filter_generator("bcc")
)
]

@staticmethod
def binaries_for_revision(
revision: ShortCommitHash
) -> tp.List[ProjectBinaryWrapper]:
binary_map = RevisionBinaryMap(get_local_project_git_path(Bcc.NAME))

binary_map.specify_binary("build/src/cc/libbcc.so", BinaryType.SHARED_LIBRARY)

return binary_map[revision]

def compile(self) -> None:
"""Compile the BCC project."""
bcc_source = local.path(self.source_of_primary)
mkdir("-p", bcc_source / "build")

cc_compiler = bb.compiler.cc(self)
cxx_compiler = bb.compiler.cxx(self)
with local.cwd(bcc_source / 'build'):
with local.env(CC=str(cc_compiler), CXX=cxx_compiler):
# llvm_path = "/lib/llvm-14/lib/cmake/llvm/"
bb.watch(cmake)("..",
# "-DCMAKE_BUILD_TYPE=Release",
# f"-DLLVM_DIR={llvm_path}",
# "-DCMAKE_POSITION_INDEPENDENT_CODE=ON",
"-DCMAKE_C_FLAGS=-fPIE", "-DCMAKE_CXX_FLAGS=-fPIE",
# "-DCMAKE_EXE_LINKER_FLAGS=-pie"
) # Configuring the project
# Compiling the project with make, specifying the number of jobs
bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))

with local.cwd(bcc_source):
verify_binaries(self)



72 changes: 72 additions & 0 deletions varats/varats/projects/c_projects/crun.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"""Project file for the Crun."""
import typing as tp

import benchbuild as bb
from benchbuild.utils.cmd import make
from benchbuild.utils.settings import get_number_of_jobs
from plumbum import local

from varats.containers.containers import get_base_image, ImageBase
from varats.paper.paper_config import (
project_filter_generator,
PaperConfigSpecificGit,
)
from varats.project.project_domain import ProjectDomains
from varats.project.project_util import (
ProjectBinaryWrapper,
BinaryType,
verify_binaries,
get_local_project_git_path,
)
from varats.project.varats_project import VProject
from varats.utils.git_util import ShortCommitHash, RevisionBinaryMap
from varats.utils.settings import bb_cfg


class Crun(VProject):

NAME = 'crun'
GROUP = 'c_projects'
DOMAIN = ProjectDomains.RUNTIME

SOURCE = [
PaperConfigSpecificGit(
project_name="crun",
remote="https://github.com/containers/crun",
local="crun",
refspec="origin/HEAD",
limit=None,
shallow=False
),
bb.source.GitSubmodule(
remote="https://github.com/containers/libocispec.git",
local="crun/libocispec",
refspec="origin/HEAD",
limit=None,
shallow=False,
version_filter=project_filter_generator("crun")
)
]

@staticmethod
def binaries_for_revision(
revision: ShortCommitHash
) -> tp.List[ProjectBinaryWrapper]:
binary_map = RevisionBinaryMap(get_local_project_git_path(Crun.NAME))

binary_map.specify_binary("crun", BinaryType.EXECUTABLE)

return binary_map[revision]

def compile(self) -> None:
crun_source = local.path(self.source_of_primary)
compiler = bb.compiler.cc(self)
with local.cwd(crun_source):
with local.env(CC=str(compiler)):
bb.watch(local["./autogen.sh"])()
bb.watch(local["./configure"])("--disable-gcc-warnings")

bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))

verify_binaries(self)

Loading
Loading