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

Upgraded fibonacci to deal with large numbers #1019

Merged
merged 2 commits into from
Jul 30, 2024
Merged
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
6 changes: 6 additions & 0 deletions .github/configs/wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ goroutine
gradle
gradlew
Gratz
grayscale
grot
Grot
gRPC
Expand Down Expand Up @@ -443,6 +444,7 @@ Prefetch
Prefetched
Prefetching
preprocessor
preprocesses
priyank
Priyank
proc
Expand Down Expand Up @@ -483,6 +485,8 @@ recommender
recommendationservice
repo
Repos
rnn
RNN
roadmap
RPC
rpc
Expand Down Expand Up @@ -535,6 +539,7 @@ Sotiria
SPECU
specversion
Sprintf
squeezenet
src
SSD
sslip
Expand Down Expand Up @@ -647,6 +652,7 @@ zA
Zhu
zipkin
Zipkin
zlib

EsjWHBuJ
HZPSfs
Expand Down
22 changes: 14 additions & 8 deletions benchmarks/fibonacci/go/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"fmt"
"net"
"strconv"
"math/big"

pb "github.com/vhive-serverless/vSwarm-proto/proto/fibonacci"
tracing "github.com/vhive-serverless/vSwarm/utils/tracing/go"
Expand All @@ -42,14 +43,19 @@ var (
address = flag.String("addr", "0.0.0.0:50051", "Address:Port the grpc server is listening to")
)

func fibonacci(num int) float64 {
var num1 float64 = 0
var num2 float64 = 1
var sum float64
func fibonacci(num int) *big.Int {
if num <= 0 {
return big.NewInt(0)
}

num1 := big.NewInt(0)
num2 := big.NewInt(1)
sum := big.NewInt(0)

for i := 0; i < num; i++ {
sum = num1 + num2
num1 = num2
num2 = sum
sum.Add(num1, num2)
num1.Set(num2)
num2.Set(sum)
}
return num1
}
Expand All @@ -64,7 +70,7 @@ func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloRe
// log.Printf("Received: %v", in.GetName())
x, _ := strconv.ParseInt(in.GetName(), 10, 64)
var y = fibonacci(int(x))
resp := fmt.Sprintf("fn: Fib: y = fib(x) | x: %d y: %.1f | runtime: GoLang", x, y)
resp := fmt.Sprintf("fn: Fib: y = fib(x) | x: %d y: %s | runtime: GoLang", x, y.String())
return &pb.HelloReply{Message: resp}, nil
}

Expand Down
8 changes: 4 additions & 4 deletions benchmarks/fibonacci/nodejs/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ var hello_proto = grpc.loadPackageDefinition(packageDefinition).fibonacci;


function fibonacci(num) {
var num1 = 0;
var num2 = 1;
var sum;
let num1 = BigInt(0);
let num2 = BigInt(1);
let sum = BigInt(0);
var i = 0;
for (i = 0; i < num; i++) {
sum = num1 + num2;
num1 = num2;
num2 = sum;
}
return num1;
return num1.toString();
}

/**
Expand Down
4 changes: 3 additions & 1 deletion benchmarks/fibonacci/python/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
tracing.grpcInstrumentClient()
tracing.grpcInstrumentServer()

sys.set_int_max_str_digits(500000)

def fibonacci(num):
num1=0
num2=1
Expand All @@ -79,7 +81,7 @@ def SayHello(self, request, context):
y = fibonacci(x)

gid = syscall(104)
msg = "fn: Fib: y = fib(x) | x: %i y: %.1f | runtime: python" % (x,y)
msg = "fn: Fib: y = fib(x) | x: %i y: %i | runtime: python" % (x,y)
return fibonacci_pb2.HelloReply(message=msg)


Expand Down
2 changes: 1 addition & 1 deletion benchmarks/video-analytics-standalone/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Video Analytics Standalone Benchmark

The video analyics standalone benchmark preprocesses an input video and runs an object detection model (squeezenet) on the video. An input video can be specified, but if nothing is given, a default video is used. This benchmark also utilises and depends on a database to store the videos that can be used, which in turn uses MongoDB.
The video analytics standalone benchmark preprocesses an input video and runs an object detection model (squeezenet) on the video. An input video can be specified, but if nothing is given, a default video is used. This benchmark also utilises and depends on a database to store the videos that can be used, which in turn uses MongoDB.

The `init-database.go` script runs when starting the function and populates the database with the videos from the `videos` folder.

Expand Down
Loading