Skip to content

Commit

Permalink
Added all files for the compression benchmark.
Browse files Browse the repository at this point in the history
Signed-off-by: L Lakshmanan <[email protected]@research.iiit.ac.in>
  • Loading branch information
Lakshman authored and dhschall committed Jul 18, 2024
1 parent 0d8aea6 commit 0da569b
Show file tree
Hide file tree
Showing 8 changed files with 2,624 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-compression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
- name: invoke the chain
run: |
./tools/bin/grpcurl -plaintext -d '{"regenerate": "false"}' localhost:50051 compression.TODO
./tools/bin/grpcurl -plaintext localhost:50000 helloworld.Greeter.SayHello
- name: invoke the relay
working-directory: tools/test-client
Expand Down
42 changes: 42 additions & 0 deletions benchmarks/compression/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# MIT License

# Copyright (c) 2024 EASE lab

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

#---------- PYTHON -----------#
# First stage (Builder):
# Install gRPC and all other dependencies
FROM vhiveease/python-slim:latest as compressionPythonBuilder
WORKDIR /py
COPY ./benchmarks/compression/python/requirements.txt ./requirements.txt
RUN pip3 install --user -r requirements.txt
COPY ./utils/tracing/python/tracing.py ./
COPY ./benchmarks/compression/files/metamorphosis.txt ./
COPY ./benchmarks/compression/python/server.py ./
ADD https://raw.githubusercontent.com/vhive-serverless/vSwarm-proto/main/proto/compression/compression_pb2_grpc.py ./
ADD https://raw.githubusercontent.com/vhive-serverless/vSwarm-proto/main/proto/compression/compression_pb2.py ./proto/compression/

# Second stage (Runner):
FROM vhiveease/python-slim:latest as compressionPython
COPY --from=compressionPythonBuilder /root/.local /root/.local
COPY --from=compressionPythonBuilder /py /app
WORKDIR /app
# ENV PATH=/root/.local/bin:$PATH
ENTRYPOINT [ "python3", "/app/server.py" ]
42 changes: 42 additions & 0 deletions benchmarks/compression/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# MIT License

# Copyright (c) 2024 EASE lab

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

ROOT = ../../
FUNCTIONS = compression-python
ALL_IMAGES = $(FUNCTIONS)

all-image: $(ALL_IMAGES)

compression-python: docker/Dockerfile python/server.py python/requirements.txt files/metamorphosis.txt
DOCKER_BUILDKIT=1 docker build \
--tag vhiveease/compression-python:latest \
--target compressionPython \
-f docker/Dockerfile \
$(ROOT) --load

## Push images
push:
docker push docker.io/vhiveease/compression-python:latest

## Pull images from docker hub
pull:
docker pull docker.io/vhiveease/compression-python:latest
2,362 changes: 2,362 additions & 0 deletions benchmarks/compression/files/metamorphosis.txt

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions benchmarks/compression/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
grpcio==1.45.0
grpcio-tools==1.45.0
opentelemetry-api==1.3.0
opentelemetry-exporter-zipkin==1.3.0
opentelemetry-exporter-zipkin-json==1.3.0
opentelemetry-exporter-zipkin-proto-http==1.3.0
opentelemetry-instrumentation==0.22b0
opentelemetry-instrumentation-grpc==0.22b0
opentelemetry-sdk==1.3.0
opentelemetry-semantic-conventions==0.22b0
73 changes: 73 additions & 0 deletions benchmarks/compression/python/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import os
import zlib
import tracing

import grpc
import argparse

from proto.compression import compression_pb2
import compression_pb2_grpc

from concurrent import futures

parser = argparse.ArgumentParser()
parser.add_argument("-a", "--addr", dest="addr", default="0.0.0.0", help="IP address")
parser.add_argument("-p", "--port", dest="port", default="50051", help="serve port")
parser.add_argument("-zipkin", "--zipkin", dest="url", default="http://0.0.0.0:9411/api/v2/spans", help="Zipkin endpoint url")
parser.add_argument("--def_file", default="metamorphosis.txt", help="Default file to be compressed if empty")

args = parser.parse_args()

if tracing.IsTracingEnabled():
tracing.initTracer("compression-python", url=args.url)
tracing.grpcInstrumentClient()
tracing.grpcInstrumentServer()

def FileCompressFunction(file_path):
try:
with open(file_path, 'rb') as f:
data = f.read()
compressed = zlib.compress(data, zlib.Z_BEST_COMPRESSION)
return f"python.compression.{compressed}"
except Exception as e:
return f"python.compression.FileNotFound.Error:{e}"

def FileDecompressFunction(file_path):
try:
with open(file_path, 'rb') as f:
data = f.read()
decompressed = zlib.decompress(data)
return decompressed
except Exception as e:
return f"python.compression.FileNotFound.Error:{e}"

class CompressFile(compression_pb2_grpc.FileCompressServicer):
def CompressFile(self, request, context):

if request.name in ["", "World"]:
filename = f"{args.def_file}"
else:
filename = f"{request.name}"

try:
with open(filename):
pass
except FileNotFoundError:
return compression_pb2.CompressedFile(data=f"python.compression.FileNotFound.Error:{filename}".encode())

with tracing.Span(name="compress_file") as span:
msg = FileCompressFunction(filename)
msg = f"fn: CompressFile | file: {filename} | message: {msg} | runtime: Python"
return compression_pb2.GetCompressedFile(message=msg)

def serve():
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
compression_pb2_grpc.add_FileCompressServicer_to_server(CompressFile(), server)
address = f"{args.addr}:{args.port}"
server.add_insecure_port(address)
print(f"Starting Python Compression server on {address}")
server.start()
server.wait_for_termination()

if __name__ == '__main__':
serve()
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# MIT License

# Copyright (c) 2024 EASE lab

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

version: "3.3"
services:
compression-python:
image: vhiveease/compression-python:latest
container_name: compression-python
entrypoint:
- python
- /app/server.py
- --addr=0.0.0.0
- --port=50051
ports:
- target: 50051

relay:
image: vhiveease/relay-latency:latest
entrypoint:
- /app/server
- --addr=0.0.0.0:50000
- --function-endpoint-url=compression-python
- --function-endpoint-port=50051
- --function-name=compression-python
- --value=metamorphosis.txt
environment:
- ENABLE_DEBUGGING=false
ports:
- published: 50000
target: 50000
45 changes: 45 additions & 0 deletions benchmarks/compression/yamls/knative/kn-compression-python.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# MIT License

# Copyright (c) 2024 EASE lab

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: compression-python
namespace: default
spec:
template:
spec:
containers:
- image: docker.io/vhiveease/relay-latency:latest
ports:
- name: h2c
containerPort: 50000
args:
- --addr=0.0.0.0:50000
- --function-endpoint-url=0.0.0.0
- --function-endpoint-port=50051
- --function-name=compression-python
- --value=metamorphosis.txt
- image: docker.io/vhiveease/compression-python:latest
args:
- --addr=0.0.0.0
- --port=50051

0 comments on commit 0da569b

Please sign in to comment.