-
Notifications
You must be signed in to change notification settings - Fork 91
Fission benchmark #56
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
base: master
Are you sure you want to change the base?
Changes from 40 commits
3a8dd2a
78605d1
c8c1012
5443c4a
25f3f0e
fd24ea3
d4f2687
a1edfae
337314c
42de6c7
3f51a5b
6148f76
eb93174
e6e6286
d6e9894
3caaa12
341dae3
f434a2b
954c5a4
68afc9d
460ca18
77004ff
0ddaded
d0775cd
7d451e9
335984b
a6415e1
e88c255
4276602
25de6ea
d6894c6
15922f7
5e816bf
f013a68
5ad80aa
36c03a6
9e1cd1c
f31b192
9933975
16ecf04
4a4403b
6846a47
4a83600
b3818fd
d732d64
c0ffa55
501f2c6
9106337
25d98dd
fcf22cc
af2ca47
46a6f07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,3 +170,6 @@ dmypy.json | |
| sebs-* | ||
| # cache | ||
| cache | ||
|
|
||
| # ide | ||
| .vscode | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const path = require('path'), fs = require('fs'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exports.handler = async function(context) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var body = JSON.stringify(context.request.body); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var unbody = JSON.parse(body); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var func = require('./function/function'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var begin = Date.now()/1000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var start = process.hrtime(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var ret = await func.handler(unbody); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var elapsed = process.hrtime(start); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var end = Date.now()/1000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var micro = elapsed[1] / 1e3 + elapsed[0] * 1e6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var is_cold = false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var fname = path.join('/tmp','cold_run'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(!fs.existsSync(fname)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_cold = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fs.closeSync(fs.openSync(fname, 'w')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| status: 200, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| body: JSON.stringify({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| begin, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| compute_time: micro, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| results_time: 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| result: ret, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_cold | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+3
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding error handling. The function currently lacks error handling. Consider wrapping the logic in a try-catch block to handle potential errors gracefully. exports.handler = async function(context) {
+ try {
var body = JSON.stringify(context.request.body);
var unbody = JSON.parse(body);
var func = require('./function/function');
var begin = Date.now()/1000;
var start = process.hrtime();
var ret = await func.handler(unbody);
var elapsed = process.hrtime(start);
var end = Date.now()/1000;
var micro = elapsed[1] / 1e3 + elapsed[0] * 1e6;
var is_cold = false;
var fname = path.join('/tmp','cold_run');
if(!fs.existsSync(fname)) {
is_cold = true;
fs.closeSync(fs.openSync(fname, 'w'));
}
return {
status: 200,
body: JSON.stringify({
begin,
end,
compute_time: micro,
results_time: 0,
result: ret,
is_cold
})
};
+ } catch (error) {
+ return {
+ status: 500,
+ body: JSON.stringify({ error: error.message })
+ };
+ }
};Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| from flask import request, jsonify, current_app | ||
|
|
||
| import json | ||
| import datetime | ||
| import os | ||
|
|
||
|
|
||
| def handler(): | ||
| body = request.get_data().decode("utf-8") | ||
| current_app.logger.info("Body: " + body) | ||
| event = json.loads(body) | ||
| current_app.logger.info("Event: " + str(event)) | ||
| begin = datetime.datetime.now() | ||
| from function import function | ||
|
|
||
| ret = function.handler(event) | ||
| end = datetime.datetime.now() | ||
| current_app.logger.info("Function result: " + str(ret)) | ||
| log_data = {"result": ret["result"]} | ||
| if "measurement" in ret: | ||
| log_data["measurement"] = ret["measurement"] | ||
|
|
||
| results_time = (end - begin) / datetime.timedelta(microseconds=1) | ||
|
|
||
| # cold test | ||
| is_cold = False | ||
| fname = "cold_run" | ||
| if not os.path.exists(fname): | ||
| is_cold = True | ||
| open(fname, "a").close() | ||
|
|
||
| return jsonify( | ||
| json.dumps( | ||
| { | ||
| "begin": begin.strftime("%s.%f"), | ||
| "end": end.strftime("%s.%f"), | ||
| "results_time": results_time, | ||
| "is_cold": is_cold, | ||
| "result": log_data, | ||
| } | ||
| ) | ||
| ) |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,60 @@ | ||||
| import os | ||||
xylini marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
| import uuid | ||||
| import json | ||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unused import. The import statement for - import jsonCommittable suggestion
Suggested change
ToolsRuff
|
||||
| import minio | ||||
| from flask import current_app | ||||
|
|
||||
|
|
||||
| class storage: | ||||
| instance = None | ||||
| client = None | ||||
|
|
||||
| def __init__(self): | ||||
| file = open(os.path.join(os.path.dirname(__file__), "minioConfig.json"), "r") | ||||
| minioConfig = json.load(file) | ||||
| try: | ||||
| self.client = minio.Minio( | ||||
| minioConfig["url"], | ||||
| access_key=minioConfig["access_key"], | ||||
| secret_key=minioConfig["secret_key"], | ||||
| secure=False, | ||||
| ) | ||||
| except Exception as e: | ||||
| current_app.logger.info(e) | ||||
|
|
||||
| @staticmethod | ||||
| def unique_name(name): | ||||
| name, extension = name.split(".") | ||||
| return "{name}.{random}.{extension}".format( | ||||
| name=name, extension=extension, random=str(uuid.uuid4()).split("-")[0] | ||||
| ) | ||||
|
|
||||
| def upload(self, bucket, file, filepath): | ||||
| key_name = storage.unique_name(file) | ||||
| self.client.fput_object(bucket, key_name, filepath) | ||||
| return key_name | ||||
|
|
||||
| def download(self, bucket, file, filepath): | ||||
| self.client.fget_object(bucket, file, filepath) | ||||
|
|
||||
| def download_directory(self, bucket, prefix, path): | ||||
| objects = self.client.list_objects_v2(bucket, prefix, recursive=True) | ||||
| for obj in objects: | ||||
| file_name = obj.object_name | ||||
| self.download(bucket, file_name, os.path.join(path, file_name)) | ||||
|
|
||||
| def upload_stream(self, bucket, file, bytes_data): | ||||
| key_name = storage.unique_name(file) | ||||
| self.client.put_object( | ||||
| bucket, key_name, bytes_data, bytes_data.getbuffer().nbytes | ||||
| ) | ||||
| return key_name | ||||
|
|
||||
| def download_stream(self, bucket, file): | ||||
| data = self.client.get_object(bucket, file) | ||||
| return data.read() | ||||
|
|
||||
| def get_instance(): | ||||
| if storage.instance is None: | ||||
| storage.instance = storage() | ||||
| return storage.instance | ||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "experiments": { | ||
| "update_code": false, | ||
| "update_storage": false, | ||
| "download_results": false, | ||
| "deployment": "fission", | ||
| "runtime": { | ||
| "language": "python", | ||
| "version": "3.6" | ||
mcopik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| }, | ||
| "deployment": { | ||
| "name": "fission", | ||
| "shouldShutdown": false | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,5 +100,35 @@ | |
| "username": "docker_user" | ||
| } | ||
| } | ||
| }, | ||
| "fission": { | ||
| "languages": { | ||
| "python": { | ||
| "base_images": { | ||
| "env":"fission/python-env:latest", | ||
|
||
| "builder":"fission/python-builder:latest" | ||
| }, | ||
| "versions": ["3.6"], | ||
| "images": [], | ||
| "username": "docker_user", | ||
| "deployment": { | ||
| "files": ["handler.py", "storage.py"], | ||
| "packages": {"minio" : "^5.0.10"} | ||
| } | ||
| }, | ||
| "nodejs": { | ||
| "base_images": { | ||
| "env":"fission/node-env:latest", | ||
| "builder":"fission/node-builder:latest" | ||
| }, | ||
| "versions": ["10.x", "12.x"], | ||
| "images": [], | ||
| "username": "docker_user", | ||
| "deployment": { | ||
| "files": ["handler.js"], | ||
| "packages": {"minio" : "^7.0.16"} | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,6 @@ | |
|
|
||
| [mypy-docker] | ||
| ignore_missing_imports = True | ||
|
|
||
| [mypy-minio] | ||
| ignore_missing_imports = True | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from .fission import Fission # noqa | ||
| from .config import FissionConfig # noqa | ||
| from .minio import Minio # noqa |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,50 @@ | ||||||||||||||||
| from sebs.faas.config import Config, Credentials, Resources | ||||||||||||||||
| from sebs.cache import Cache | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| class FissionCredentials(Credentials): | ||||||||||||||||
| def __init__(self): | ||||||||||||||||
| pass | ||||||||||||||||
|
|
||||||||||||||||
| @staticmethod | ||||||||||||||||
| def initialize(config: dict, cache: Cache) -> Credentials: | ||||||||||||||||
|
||||||||||||||||
| return FissionCredentials() | ||||||||||||||||
|
|
||||||||||||||||
| def serialize(self) -> dict: | ||||||||||||||||
| pass | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| class FissionResources(Resources): | ||||||||||||||||
| def __init__(self): | ||||||||||||||||
| pass | ||||||||||||||||
|
|
||||||||||||||||
| def serialize(self) -> dict: | ||||||||||||||||
| return {} | ||||||||||||||||
|
|
||||||||||||||||
| @staticmethod | ||||||||||||||||
| def initialize(config: dict, cache: Cache) -> Resources: | ||||||||||||||||
| pass | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| class FissionConfig(Config): | ||||||||||||||||
| name: str | ||||||||||||||||
| cache: Cache | ||||||||||||||||
| shouldShutdown: bool | ||||||||||||||||
|
Comment on lines
+259
to
+262
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the The class FissionConfig(Config):
name: str
cache: Cache
- shouldShutdown: boolCommittable suggestion
Suggested change
|
||||||||||||||||
|
|
||||||||||||||||
| def __init__(self, config: dict, cache: Cache): | ||||||||||||||||
| self.name = config["name"] | ||||||||||||||||
| self.shouldShutdown = config["shouldShutdown"] | ||||||||||||||||
|
||||||||||||||||
| self.cache = cache | ||||||||||||||||
|
|
||||||||||||||||
| @staticmethod | ||||||||||||||||
| def initialize(config: dict, cache: Cache) -> Config: | ||||||||||||||||
| return FissionConfig(config, cache) | ||||||||||||||||
|
|
||||||||||||||||
| def credentials(self) -> Credentials: | ||||||||||||||||
| pass | ||||||||||||||||
|
|
||||||||||||||||
| def resources(self) -> Resources: | ||||||||||||||||
| pass | ||||||||||||||||
|
|
||||||||||||||||
| def serialize(self) -> dict: | ||||||||||||||||
| pass | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all wrappers, we need to compare them against newest implementation in OpenWhisk/Knative - there have been changes. In particular, storage triggers received few bugfixes.