Skip to content

Commit

Permalink
Update tailbench packages and edited tailbench benchmark to account f…
Browse files Browse the repository at this point in the history
…or OpenCV and Python upgrade.

PiperOrigin-RevId: 538820325
  • Loading branch information
andyz422 authored and copybara-github committed Jun 8, 2023
1 parent fcc696b commit 3fc8591
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 13 deletions.
60 changes: 60 additions & 0 deletions perfkitbenchmarker/data/tailbench.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
diff --git a/img-dnn/Makefile b/img-dnn/Makefile
index d022b0b..fce3d9e 100644
--- a/img-dnn/Makefile
+++ b/img-dnn/Makefile
@@ -1,6 +1,6 @@
CXX = g++
-CXXFLAGS += -g -O3 $(shell pkg-config --cflags opencv) -std=c++0x
-LDFLAGS = $(shell pkg-config --libs opencv)
+CXXFLAGS += -g -O3 $(shell pkg-config --cflags opencv4) -std=c++0x
+LDFLAGS = $(shell pkg-config --libs opencv4)

TBENCH_PATH = ../harness
TBENCH_SERVER_OBJ = $(TBENCH_PATH)/tbench_server_networked.o
diff --git a/img-dnn/img-dnn.cpp b/img-dnn/img-dnn.cpp
index bcb66ce..8d120a6 100644
--- a/img-dnn/img-dnn.cpp
+++ b/img-dnn/img-dnn.cpp
@@ -11,6 +11,7 @@
#include "tbench_server.h"

#include "opencv2/core/core.hpp"
+#include <opencv2/core/core_c.h>
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"

diff --git a/img-dnn/train.cpp b/img-dnn/train.cpp
index c1c4bc6..61327f6 100644
--- a/img-dnn/train.cpp
+++ b/img-dnn/train.cpp
@@ -1,5 +1,6 @@
#include "common.h"

+#include <opencv2/core/core_c.h>
#include <unistd.h>

#include <iostream>
diff --git a/utilities/parselats.py b/utilities/parselats.py
index 7bd1949..78700cb 100755
--- a/utilities/parselats.py
+++ b/utilities/parselats.py
@@ -9,7 +9,7 @@ class Lat(object):
def __init__(self, fileName):
f = open(fileName, 'rb')
a = np.fromfile(f, dtype=np.uint64)
- self.reqTimes = a.reshape((a.shape[0]/3, 3))
+ self.reqTimes = a.reshape((int(a.shape[0]/3), 3))
f.close()

def parseQueueTimes(self):
@@ -41,8 +41,8 @@ if __name__ == '__main__':
f.close()
p95 = stats.scoreatpercentile(sjrnTimes, 95)
maxLat = max(sjrnTimes)
- print "95th percentile latency %.3f ms | max latency %.3f ms" \
- % (p95, maxLat)
+ print("95th percentile latency %.3f ms | max latency %.3f ms" \
+ % (p95, maxLat))

latsFile = sys.argv[1]
getLatPct(latsFile)
36 changes: 23 additions & 13 deletions perfkitbenchmarker/linux_packages/tailbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
HEADER_LINES = 3


class _TestResult():
class _TestResult:

def __init__(self, values: List[float], name: str, subname: str):
self.histogram: sample._Histogram = sample.MakeHistogram(values, 0.95, 2)
Expand All @@ -77,16 +77,17 @@ def Install(vm):
"""Installs the tailbench dependencies and sets up the package on the VM."""
# TODO(user): Rework all of this to use vm.Install to make more robust
vm.InstallPackages(
'libopencv-dev autoconf ant libtcmalloc-minimal4 swig google-perftools '
'bzip2 libnuma-dev libjemalloc-dev libgoogle-perftools-dev '
'libdb5.3++-dev libmysqld-dev libaio-dev uuid-dev libbz2-dev '
'python-numpy python-scipy libgtop2-dev make g++ zlib1g-dev pkg-config '
'pocketsphinx libboost-all-dev'
'libopencv-dev autoconf ant libtcmalloc-minimal4 swig google-perftools'
' bzip2 libnuma-dev libjemalloc-dev libgoogle-perftools-dev'
' libdb5.3++-dev libmysqlclient-dev libaio-dev uuid-dev libbz2-dev'
' python-numpy python3-scipy libgtop2-dev make g++ zlib1g-dev pkg-config'
' pocketsphinx libboost-all-dev'
)
vm.Install('openjdk')

vm.InstallPreprovisionedPackageData(PACKAGE_NAME,
PREPROVISIONED_DATA.keys(), INSTALL_DIR)
vm.InstallPreprovisionedPackageData(
PACKAGE_NAME, PREPROVISIONED_DATA.keys(), INSTALL_DIR
)

vm.RemoteCommand(f'cd {INSTALL_DIR} && tar xf {TAILBENCH_TAR}')
vm.RemoteCommand(f'cd {INSTALL_DIR} && tar xf {TAILBENCH_INPUT_TAR}')
Expand All @@ -100,10 +101,19 @@ def PrepareTailBench(vm):
Args:
vm: The VM in which we are setting up the TailBench config.
"""
vm.RemoteCommand(f'echo "{CONFIGS_SH_CONTENTS}" > '
f'"{INSTALL_DIR}"/{TAILBENCH}/configs.sh')
vm.RemoteCommand(f'echo "{MAKEFILE_CONFIG_CONTENTS}" > '
f'"{INSTALL_DIR}"/{TAILBENCH}/Makefile.config')
vm.RemoteCommand(
f'echo "{CONFIGS_SH_CONTENTS}" > "{INSTALL_DIR}"/{TAILBENCH}/configs.sh'
)
vm.RemoteCommand(
f'echo "{MAKEFILE_CONFIG_CONTENTS}" > '
f'"{INSTALL_DIR}"/{TAILBENCH}/Makefile.config'
)
vm.PushDataFile(
'tailbench.patch', f'{INSTALL_DIR}/{TAILBENCH}/tailbench.patch'
)
vm.RemoteCommand(
f'cd {INSTALL_DIR}/{TAILBENCH} && patch -l -p1 < tailbench.patch'
)


def _ParseResultsFile(input_file, name='') -> List[_TestResult]:
Expand Down Expand Up @@ -180,7 +190,7 @@ def RunTailbench(vm, tailbench_tests):
vm.RemoteCommand(f'cd {INSTALL_DIR}/{TAILBENCH}/{test} && sudo ./run.sh')
vm.RemoteCommand(
f'cd {INSTALL_DIR} && '
f'sudo python2 {INSTALL_DIR}/{TAILBENCH}/utilities/parselats.py '
f'sudo python3 {INSTALL_DIR}/{TAILBENCH}/utilities/parselats.py '
f'{INSTALL_DIR}/{TAILBENCH}/{test}/lats.bin')
vm.RemoteCommand(f'sudo mv {INSTALL_DIR}/lats.txt '
f'{INSTALL_DIR}/results/{test}.txt')

0 comments on commit 3fc8591

Please sign in to comment.