-
Notifications
You must be signed in to change notification settings - Fork 5
Snafu Open Science Notebook
This wiki is used to track scientific studies and experiments with Snafu.
Performance:
time aws [--endpoint-url http://localhost:10000] [--cli-read-timeout 0] lambda invoke --function-name fib.lambda_handler --payload '{"x": 12}' /tmp/fib.log
Fibonacci function for Snafu:
import time import math import json from boto3 import client as boto3_client lambda_client = boto3_client('lambda', endpoint_url='http://localhost:10000')
lambda_client._endpoint.timeout = 300 # comment for reaper
def fib(x): msg = {"x": x} import sys fullresponse = lambda_client.invoke(FunctionName="fib.lambda_handler", Payload=json.dumps(msg)) response = json.loads(fullresponse["Payload"].read().decode("utf-8")) return response["ret"]
def lambda_handler(event, context): #time.sleep(0.1) # uncomment for reaper x = event["x"] if x in (1, 2): return {"ret": 1} ret = fib(x - 1) + fib(x - 2) ret = {'ret': ret} return ret
Fibonacci function for Lambda:
import time import math import json from boto3 import client as boto3_client lambda_client = boto3_client('lambda')
lambda_client._endpoint.timeout = 300 # comment for reaper
def fib(x): msg = {"x": x} import sys fullresponse = lambda_client.invoke(FunctionName="fib", Payload=json.dumps(msg)) response = json.loads(fullresponse["Payload"].read()) return response["ret"]
def lambda_handler(event, context): #time.sleep(0.1) # uncomment for reaper x = event["x"] if x in (1, 2): return {"ret": 1} ret = fib(x - 1) + fib(x - 2) ret = {'ret': ret} return ret
#!/bin/bash
running in parallel to: time aws --endpoint-url http://localhost:10000 lambda invoke --function-name fib.lambda_handler --payload '{"x": 20}' /tmp/_fiblog
or: time aws --endpoint-url http://localhost:10000 lambda invoke --function-name sleep.lambda_handler --payload '{}' /tmp/_sleeplog
Open sockets tracking:
log=/tmp/_lsofsnafu csv=lsof-tracker.csv echo "now,est,cwt" > $csv
start=
date +%s.%N
while true do sudo lsof -i TCP | grep snafu | grep IPv4 > $log est=grep ESTABLISHED $log | wc -l
cwt=grep CLOSE_WAIT $log | wc -l
now=date +%s.%N
#stamp=$(($now-$start)) stamp=echo "print('{:.2f}'.format(" $now - $start "))" | python3
echo $stamp,$est,$cwt >> $csv sleep 0.1 done