Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
179 commits
Select commit Hold shift + click to select a range
35d57bc
just a test with a multi-arch image
FilippoMuschera Oct 6, 2025
ac74f01
PATCH: etcd image set to bitnamilegacy due to bitnami changes to dock…
FilippoMuschera Oct 16, 2025
6ad54e3
Updated Go version to 1.24
FilippoMuschera Oct 16, 2025
876b23e
Set dockerhub to "fmuschera" for multi-arch images
FilippoMuschera Oct 16, 2025
1e7638a
Set dockerhub to "fmuschera" for multi-arch images
FilippoMuschera Oct 16, 2025
1dd53dd
Revert "Set dockerhub to "fmuschera" for multi-arch images"
FilippoMuschera Oct 16, 2025
2277c78
Changed etcd image (test for ARM test run)
FilippoMuschera Oct 16, 2025
d38d8d1
changed dockerhub source for multi-arch tests
FilippoMuschera Oct 16, 2025
3e61d58
additional logging for test
FilippoMuschera Oct 17, 2025
9b943d1
Revert "additional logging for test"
FilippoMuschera Oct 17, 2025
0a0cac8
typo fix
FilippoMuschera Oct 17, 2025
3b10925
Added 'make clean'
FilippoMuschera Oct 17, 2025
6edaa84
Merge remote-tracking branch 'origin/main'
FilippoMuschera Oct 17, 2025
d90241e
Temporarily reduced CPUDemand of tests to test it on small VM over Cl…
FilippoMuschera Oct 17, 2025
c97702b
Enhance node registration with architecture
FilippoMuschera Oct 25, 2025
0e167e1
Enhance custom runtime support
FilippoMuschera Oct 25, 2025
6c9b3ce
Update go.mod and go.sum dependencies
FilippoMuschera Oct 26, 2025
2b531e0
Minor fixes
FilippoMuschera Oct 26, 2025
556ccf0
Add image architecture detection tests
FilippoMuschera Oct 26, 2025
091b5ed
Improve docker image architecture test
FilippoMuschera Oct 27, 2025
66063c7
Improved image architecture caching
FilippoMuschera Oct 27, 2025
5819880
Improve test setup/teardown for better stability
FilippoMuschera Oct 27, 2025
14d9d27
New workflow to run all tests upon push
FilippoMuschera Oct 27, 2025
c87048e
Improve architecture support
FilippoMuschera Oct 27, 2025
5cbf85a
Make policies architecture-aware
FilippoMuschera Oct 27, 2025
bf7fe05
fix: f.SupportedArchs assignment was getting potentially skipped due …
FilippoMuschera Oct 29, 2025
5e7e482
Add architecture constants to util.go so that they use the new Suppor…
FilippoMuschera Oct 29, 2025
69e98b2
Add arch mismatch test
FilippoMuschera Oct 29, 2025
2c74e47
Increase sleep duration in API test
FilippoMuschera Oct 29, 2025
a2d358a
Consider node architecture when offloading
FilippoMuschera Oct 29, 2025
cd0640d
Implement architecture-aware offloading, with choice caching and choo…
FilippoMuschera Oct 29, 2025
95fc604
fix: Swap Arch and Key in registry paths
FilippoMuschera Oct 29, 2025
56f8d00
Improve edge offloading policy
FilippoMuschera Oct 30, 2025
5833b27
Correctly handle offloading logic
FilippoMuschera Oct 30, 2025
fd20fdf
Refactoring config key for local fallback
FilippoMuschera Oct 30, 2025
31608e1
Fix: moved initialization of 'fallBackLocally' to the Init function.
FilippoMuschera Oct 30, 2025
0eb9724
use ArchitectureAwareBalancer
FilippoMuschera Nov 15, 2025
a5e1a89
Add architecture-aware load balancer
FilippoMuschera Nov 15, 2025
d54fdd3
implement consistent hashing with HashRing
FilippoMuschera Nov 15, 2025
ac6a078
Add architecture-aware load balancer tests
FilippoMuschera Nov 15, 2025
2cd416a
updated docker version
FilippoMuschera Nov 16, 2025
597365d
Documenting better the code
FilippoMuschera Nov 16, 2025
3b270f4
Making consistent hashing memory-aware
FilippoMuschera Nov 16, 2025
0cbf27b
add TestGetNodeFromRing to architectureAwareLb
FilippoMuschera Nov 16, 2025
a42aab9
Added fallback to different architecture for the lb
FilippoMuschera Nov 16, 2025
4fd5271
add TestGetArchFallback to architectureAwareLb
FilippoMuschera Nov 16, 2025
6cd11f9
Make ArchitectureAwareBalancer replicas configurable
FilippoMuschera Nov 17, 2025
a387846
buxfix: Correctly concatenate directory path for load balancers
FilippoMuschera Nov 17, 2025
fca496c
chore(container): Add TODO comment for cache TTL
FilippoMuschera Nov 17, 2025
454ebf7
Merge pull request #1 from FilippoMuschera/ArchitectureAware
FilippoMuschera Nov 23, 2025
5905fab
Add Java 21 runtime
FilippoMuschera Nov 23, 2025
59ec8cb
Add HelloFunction Java example and JAR
FilippoMuschera Nov 23, 2025
eca5ef1
Add Java function testing and refactor api_test.go
FilippoMuschera Nov 23, 2025
b567974
Update CI workflow to run all tests
FilippoMuschera Nov 23, 2025
d72a1d0
Update CI workflow to run all tests
FilippoMuschera Nov 23, 2025
c1565fa
Upgrade Python runtime to 3.14
FilippoMuschera Nov 24, 2025
98647dd
Add server readiness check in TestMain
FilippoMuschera Nov 24, 2025
f0318cb
Add metrics headers to API responses to notify the LB of the free mem…
FilippoMuschera Nov 26, 2025
180dfd4
Add function to get single neighbor info
FilippoMuschera Nov 26, 2025
52bacda
Add LastUpdateTime to types.go
FilippoMuschera Nov 26, 2025
921cae8
Add dynamic memory update for proxy targets
FilippoMuschera Nov 26, 2025
13689e7
Improve memory awareness of the architecture aware load balancer
FilippoMuschera Nov 26, 2025
8b56ccb
Merge pull request #2 from FilippoMuschera/ExtendedRuntimes
FilippoMuschera Nov 27, 2025
473124b
Add server readiness check in TestMain
FilippoMuschera Nov 24, 2025
e723b37
Minor fix to AllMemoryAvailable
FilippoMuschera Nov 27, 2025
737d5e7
Update memory after function execution
FilippoMuschera Nov 27, 2025
a70199a
Update available memory sent to the LB ensuring it includes memory fr…
FilippoMuschera Nov 27, 2025
5e181e3
Fix (as suggested by professor Russo Russo): execution thread will no…
FilippoMuschera Nov 28, 2025
b0d68af
refactor(registration): Remove unused GetSingleNeighborInfo function
FilippoMuschera Nov 29, 2025
f6fdbc3
Add LB refresh interval configuration
FilippoMuschera Nov 29, 2025
eec0884
Improve info updates of load balancer from targets
FilippoMuschera Nov 29, 2025
3749562
Improve info updates of load balancer from targets
FilippoMuschera Nov 29, 2025
d73a130
Implement decision caching for architecture selection
FilippoMuschera Nov 30, 2025
702a44d
Improve architecture-aware balancer cache
FilippoMuschera Nov 30, 2025
a00052a
Merge pull request #3 from FilippoMuschera/ArchAndMemoryAwareLB
FilippoMuschera Nov 30, 2025
25a0904
Update Python runtime version in README
FilippoMuschera Nov 30, 2025
074f838
Preparing new Go 1.25 runtime
FilippoMuschera Nov 30, 2025
36903ca
Add Go 1.25 runtime support
FilippoMuschera Nov 30, 2025
d3228ec
Add go125 runtime support
FilippoMuschera Nov 30, 2025
cac18b7
Set log output for user handler
FilippoMuschera Nov 30, 2025
75005bc
Increase etcd message size limit
FilippoMuschera Nov 30, 2025
f155374
Correctly restore old log writer
FilippoMuschera Dec 1, 2025
6fd3cf1
Add Go example with build and docs
FilippoMuschera Dec 1, 2025
f9df43a
Update Go example source path
FilippoMuschera Dec 1, 2025
9a97812
Pass ReturnOutput in invocation request
FilippoMuschera Dec 1, 2025
c1826ff
Remove local replace
FilippoMuschera Dec 1, 2025
819852d
New python runtime for Ml purposes. Add Dockerfile and executor
FilippoMuschera Dec 2, 2025
2e9a893
Add new python312ml runtime
FilippoMuschera Dec 2, 2025
f4dd4d2
Add new ML example for python312ml runtime
FilippoMuschera Dec 2, 2025
be11a8a
Add option to pass a link to the code instead of the source file dire…
FilippoMuschera Dec 3, 2025
330987a
Remove higher message size limits
FilippoMuschera Dec 3, 2025
0842a21
Refactor ContainerPool to use slices instead of linked lists
FilippoMuschera Dec 14, 2025
dd40b81
Update comment
FilippoMuschera Jan 2, 2026
49cc241
Implement Multi-Armed Bandit (MAB) for architecture selection
FilippoMuschera Jan 2, 2026
94e3ce2
Add script to start global etcd registry
FilippoMuschera Jan 2, 2026
49e31ce
fix: Correct URL validation print statement
FilippoMuschera Jan 2, 2026
6400feb
Use both internal and public IPs for etcd
FilippoMuschera Jan 2, 2026
a94761b
fix: Skip MAB if only one arch supported
FilippoMuschera Jan 2, 2026
85ef011
Update architecture aware balancer tests to consider the presence of …
FilippoMuschera Jan 2, 2026
133cadc
Preparing MAB (ucb1) vs baseline (round robin) comparison to be run i…
FilippoMuschera Jan 3, 2026
2df49b6
Possible fix to missing header
FilippoMuschera Jan 3, 2026
8d0ef94
Fix memory configuration
FilippoMuschera Jan 3, 2026
b5af61b
Add pause to MAB comparison
FilippoMuschera Jan 3, 2026
64295b3
Path fixes
FilippoMuschera Jan 3, 2026
26b0817
typo fix
FilippoMuschera Jan 3, 2026
b2292d0
fix: removed double usage of mutex to avoid deadlock
FilippoMuschera Jan 3, 2026
2f53e9f
Update to constant values
FilippoMuschera Jan 3, 2026
d059f77
Update to constant values
FilippoMuschera Jan 3, 2026
f5a4c07
Update to constant values
FilippoMuschera Jan 3, 2026
053f6d2
Update to constant values
FilippoMuschera Jan 3, 2026
d66a3ef
Additional logging for debugging
FilippoMuschera Jan 4, 2026
8f69130
Tweak reward value
FilippoMuschera Jan 4, 2026
a81c083
Tweak reward value
FilippoMuschera Jan 4, 2026
24b909f
Add architecture choice timeline plot
FilippoMuschera Jan 4, 2026
c80e434
Update UCB1 bandit logic and reward calculation
FilippoMuschera Jan 4, 2026
4d8bc4a
Adjust MAB UCB1 and experiment script
FilippoMuschera Jan 4, 2026
7748449
More function experiments
FilippoMuschera Jan 5, 2026
dc618f6
update
FilippoMuschera Jan 5, 2026
1a4c1ff
update
FilippoMuschera Jan 5, 2026
e1ea736
update
FilippoMuschera Jan 5, 2026
f3f32ed
New experimental setup
FilippoMuschera Jan 5, 2026
10aaa62
New experimental setup
FilippoMuschera Jan 5, 2026
5728cd4
Add AMD and ARM optimized functions
FilippoMuschera Jan 6, 2026
2eabd34
build: Exclude examples from test command
FilippoMuschera Feb 3, 2026
ba6de87
api: add request ID header to HTTP responses
FilippoMuschera Feb 3, 2026
22b05f3
lb: Refactor LinUCB MAB and node metrics updates
FilippoMuschera Feb 3, 2026
1676280
mab: Add policy interface and context struct
FilippoMuschera Feb 3, 2026
141de33
mab: add context storage for LinUCB
FilippoMuschera Feb 3, 2026
6a38f91
mab: Add MAB bandit manager
FilippoMuschera Feb 3, 2026
1462732
mab: Refactor UCB1 bandit manager and arm selection
FilippoMuschera Feb 3, 2026
4fe11ca
config: Add MAB policy and LinUCB alpha configuration keys
FilippoMuschera Feb 3, 2026
cab4975
lb: enhance memory metrics with total memory and context
FilippoMuschera Feb 3, 2026
31134c5
mab: pass request context to bandit update
FilippoMuschera Feb 3, 2026
aa8e27f
lb: Update node metrics to include total memory
FilippoMuschera Feb 3, 2026
77319eb
lb: Optimize hash ring node management
FilippoMuschera Feb 3, 2026
9d33061
go.mod: update go runtime and add gonum
FilippoMuschera Feb 3, 2026
c02b73c
mab: add LinUCB disjoint policy implementation
FilippoMuschera Feb 3, 2026
0785457
lb: Set default load balancer mode to round robin
FilippoMuschera Feb 4, 2026
3789649
build: update go module dependencies
FilippoMuschera Feb 4, 2026
283463e
mab: Add GetType method to Bandit Policy interface
FilippoMuschera Feb 4, 2026
d706db7
mab: Refactor bandit reward calculation and UCB1 redaction
FilippoMuschera Feb 4, 2026
1254b19
mab: Update LinUCB alpha default and improve logging
FilippoMuschera Feb 4, 2026
1478176
mab: Fix comment typo in UpdateReward function
FilippoMuschera Feb 4, 2026
81eb5dd
lb: Remove MAB request ID header
FilippoMuschera Feb 4, 2026
cbbb35d
mab: parameterize UCB1 exploration constant
FilippoMuschera Feb 4, 2026
3f71540
mab: Refactor bandit reward update logic
FilippoMuschera Feb 5, 2026
6d42ad8
experiments: Add CPU hogger and LinUCB MAB experiment setup
FilippoMuschera Feb 6, 2026
55fdbb0
examples/experiments: Improve cpu_hogger.sh output format
FilippoMuschera Feb 6, 2026
b442ead
docs: add new plotting scripts and update existing one
FilippoMuschera Feb 6, 2026
7ad41d8
mab: Refactor ctx handling in UCB1 bandit
FilippoMuschera Feb 6, 2026
0ddf70d
examples/experiments: Adjust script to support 3-way experiments
FilippoMuschera Feb 6, 2026
a0a3240
mab: Adjust UCB1 min sample count
FilippoMuschera Feb 6, 2026
1684894
Merge pull request #4 from FilippoMuschera/LinUCB_MAB
FilippoMuschera Feb 7, 2026
9ca1e1a
experiments: update files to work with new deployment system
FilippoMuschera Feb 20, 2026
baaad21
experiments: update files to work with new deployment system
FilippoMuschera Feb 20, 2026
cd86292
experiments: update files to work with new deployment system
FilippoMuschera Feb 20, 2026
4120c09
experiments: update files to work with new deployment system
FilippoMuschera Feb 20, 2026
3c442c5
Merge remote-tracking branch 'origin/main'
FilippoMuschera Feb 20, 2026
f3a07e5
experiments: fix deadlock introduced in previous commit
FilippoMuschera Feb 20, 2026
2e5f677
fix: mab: Use config constant for LinUCB alpha parameter
FilippoMuschera Feb 21, 2026
6be2850
mab: Add memory penalty to LinUCB reward function
FilippoMuschera Feb 21, 2026
3281666
experiments: adjust locust and comparison script parameters
FilippoMuschera Feb 21, 2026
f043cee
experiments: adjust function for experiments
FilippoMuschera Feb 21, 2026
64fe4e3
experiments: adjust function for experiments
FilippoMuschera Feb 21, 2026
fdd1e0b
experiments: adjust experiments values
FilippoMuschera Feb 21, 2026
c530dcf
experiments: adjust experiments values
FilippoMuschera Feb 21, 2026
7f2c65d
experiments: adjust experiments values
FilippoMuschera Feb 21, 2026
d187933
experiments: adjust experiments values
FilippoMuschera Feb 21, 2026
22d2723
lb: Add random architecture selection mode
FilippoMuschera Feb 21, 2026
f1ebe5c
experiments: refinements
FilippoMuschera Feb 22, 2026
580cd55
api: emergency fix to a deadlock in GetServerStatus
FilippoMuschera Feb 22, 2026
9e952d2
experiments: prepare experiment with noisy neighbor
FilippoMuschera Feb 22, 2026
518a55d
lb: add CPU utilization to node metrics
FilippoMuschera Feb 22, 2026
f2d396f
experiments: add janitor interval to worker config
FilippoMuschera Feb 22, 2026
38c1608
config: introduce offloading cache validity configuration
FilippoMuschera Feb 25, 2026
ab53b05
lb: Increase default replica count for architecture-aware load balancer
FilippoMuschera Feb 26, 2026
d23f79d
refactor(api, lb): address GetServerStatus deadlock and update metrics
FilippoMuschera Feb 27, 2026
56b7485
mab: Adjust LinUCB memory penalty threshold
FilippoMuschera Mar 2, 2026
0f7372d
experiments: Adjust load testing parameters
FilippoMuschera Mar 3, 2026
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
26 changes: 26 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Run Tests CI

on:
push:


jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: "1.24.0"

- name: Checkout branch
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}

- name: Install dependencies
run: make

- name: Run tests
run: make unit-test && make test
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ serverledge-cli:
executor:
CGO_ENABLED=0 $(GO) build -o $(BIN)/$@ cmd/$@/executor.go

DOCKERHUB_USER=grussorusso
DOCKERHUB_USER=fmuschera
images: image-python310 image-nodejs17ng image-base
image-python310:
docker build -t $(DOCKERHUB_USER)/serverledge-python310 -f images/python310/Dockerfile .
Expand All @@ -28,8 +28,16 @@ push-images:
docker push $(DOCKERHUB_USER)/serverledge-base
docker push $(DOCKERHUB_USER)/serverledge-nodejs17ng

# Runs integration tests (all tests EXCEPT unit tests)
test:
go test -v ./...
$(GO) test -v $(shell $(GO) list ./... | grep -Ev 'internal/container|examples')

.PHONY: serverledge serverledge-cli lb executor test images
# Runs only unit tests
unit-test:
go test -v -short ./internal/container/... ./internal/lb/...

.PHONY: serverledge serverledge-cli lb executor test unit-test integration-test images

clean:
@test -n "$(BIN)" && [ -d "$(BIN)" ] && rm -rf $(BIN) || { echo "Invalid BIN directory: $(BIN)"; exit 1; } && go clean -testcache

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ Start a local Serverledge node:

Register a function `func` from example python code (the handler is formatted like this: $(filename).$(functionName)):

$ bin/serverledge-cli create -f func --memory 600 --src examples/hello.py --runtime python310 --handler "hello.handler"
$ bin/serverledge-cli create -f func --memory 600 --src examples/hello.py --runtime python314 --handler "hello.handler"

Register a function `func` from example javascript code (the handler is formatted like this: $(filename) and the name of the function is "handler"):

$ bin/serverledge-cli create -f func --memory 600 --src examples/hello.js --runtime nodejs17 --handler "hello"
$ bin/serverledge-cli create -f func --memory 600 --src examples/inc.js --runtime nodejs17 --handler "inc"
$ bin/serverledge-cli create -f func --memory 600 --src examples/hello.js --runtime nodejs17ng --handler "hello"
$ bin/serverledge-cli create -f func --memory 600 --src examples/inc.js --runtime nodejs17ng --handler "inc"

Invoke `func` with arguments `a=2` and `b=3`:

Expand Down
5 changes: 4 additions & 1 deletion cmd/lb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package main

import (
"fmt"
"github.com/serverledge-faas/serverledge/internal/node"
"log"
"os"
"os/signal"
"time"

"github.com/serverledge-faas/serverledge/internal/mab"
"github.com/serverledge-faas/serverledge/internal/node"

"golang.org/x/net/context"

"github.com/labstack/echo/v4"
Expand Down Expand Up @@ -59,5 +61,6 @@ func main() {
// Register a signal handler to cleanup things on termination
registerTerminationHandler(e)

mab.InitBanditManager()
lb.StartReverseProxy(e, myArea)
}
29 changes: 29 additions & 0 deletions examples/HelloFunction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.test;

// The compiled jar used by serverledge-cli is in ./java_build/target


import java.util.Map;
import java.util.HashMap;


public class HelloFunction {


public Map<String, Object> handler(Object params, Map<String, Object> context) {
// Test output capture (stdout)
System.out.println("Log: Iniziata esecuzione Java Function!");
System.out.println("Log: Parametri ricevuti: " + params);

// Test output capture (stderr)
System.err.println("[DEBUG]: This is a debug message on stderr");


Map<String, Object> result = new HashMap<>();
result.put("message", "Hello from the Java default runtime of Serverledge!");
result.put("received_params", params);
result.put("java_version", System.getProperty("java.version"));

return result;
}
}
63 changes: 63 additions & 0 deletions examples/experiments/amd-faster.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package main

import (
"crypto/aes"
"crypto/cipher"
"runtime"

"github.com/serverledge-faas/serverledge/serverledge"
)

// Handler is the entry point for Serverledge.
// It performs AES-GCM encryption on a generated dataset.
func myHandler(params map[string]interface{}) (interface{}, error) {
// Default data size: 128MB
dataSize := 256 * 1024 * 1024
if val, ok := params["size"].(float64); ok {
dataSize = int(val)
}

// Default passes: 5
passes := 5

// Prepare random-like data (deterministic fill to avoid generation overhead)
data := make([]byte, dataSize)
for i := 0; i < len(data); i++ {
data[i] = byte(i)
}

key := make([]byte, 32) // 256-bit key
nonce := make([]byte, 12)

block, err := aes.NewCipher(key)
if err != nil {
panic(0)
}

aesgcm, err := cipher.NewGCM(block)
if err != nil {
panic(0)
}

// Destination buffer with capacity for overhead
dst := make([]byte, 0, len(data)+aesgcm.Overhead())

// Execution: Encrypt data multiple times on a single thread
// This stresses the CPU pipeline and vector instructions (VAES/NEON)
for i := 0; i < passes; i++ {
dst = aesgcm.Seal(dst[:0], nonce, data, nil)
}

return map[string]interface{}{
"message": "AES encryption completed",
"processed_gb": (float64(dataSize) * float64(passes)) / 1024 / 1024 / 1024,
"passes": passes,
"arch": runtime.GOARCH,
}, nil
}

func main() {
// Start the Serverledge runtime. This is a blocking function since it will start an HTTP server inside the
// container, waiting for the signal to execute the function.
serverledge.Start(myHandler)
}
Binary file added examples/experiments/amd_faster.tar
Binary file not shown.
Binary file added examples/experiments/amd_faster.zip
Binary file not shown.
Binary file added examples/experiments/amd_fasterV2.tar
Binary file not shown.
74 changes: 74 additions & 0 deletions examples/experiments/arm-faster.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package main

import (
"compress/gzip"
"io"
"runtime"
"sync"

"github.com/serverledge-faas/serverledge/serverledge"
_ "go.uber.org/automaxprocs"
)

// Handler is the entry point for Serverledge.
// It performs parallel Gzip compression utilizing all available logical CPUs.
func myHandler(params map[string]interface{}) (interface{}, error) {
// Default base size: 128MB
baseSize := 256 * 1024 * 1024
if val, ok := params["size"].(float64); ok {
baseSize = int(val)
}

// Multiplier to increase total workload: default 4
multiplier := 10

// Prepare data
data := make([]byte, baseSize)
for i := 0; i < len(data); i++ {
data[i] = byte(i)
}

// Detect available CPUs to spawn correct number of goroutines
numThreads := runtime.NumCPU()

// Calculate total workload and chunk size per thread
totalDataSize := baseSize * multiplier
chunkSize := totalDataSize / numThreads
if chunkSize > len(data) {
chunkSize = len(data)
}

var wg sync.WaitGroup

// Execution: Parallel compression
for t := 0; t < numThreads; t++ {
wg.Add(1)
go func() {
defer wg.Done()

// We define the source slice based on chunk size.
// Note: We are compressing the same memory region repeatedly if total > base,
// but this is fine for testing CPU throughput.
src := data[:chunkSize]

w := gzip.NewWriter(io.Discard)
_, _ = w.Write(src)
w.Close()
}()
}

wg.Wait()

return map[string]interface{}{
"message": "Gzip compression completed",
"total_size": totalDataSize,
"arch": runtime.GOARCH,
"cpu": runtime.NumCPU(),
}, nil
}

func main() {
// Start the Serverledge runtime. This is a blocking function since it will start an HTTP server inside the
// container, waiting for the signal to execute the function.
serverledge.Start(myHandler)
}
11 changes: 11 additions & 0 deletions examples/experiments/arm-target.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
registry:
area: "cloud-region"
udp.port: 9877


etcd:
address: "5.6.7.8:2379" # set to IP of VM hosting the LB (public one)

container:
pool:
memory: 4096
Binary file added examples/experiments/arm_faster.tar
Binary file not shown.
Binary file added examples/experiments/arm_faster.zip
Binary file not shown.
Binary file added examples/experiments/arm_fasterV2.tar
Binary file not shown.
20 changes: 20 additions & 0 deletions examples/experiments/cpu_hogger.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OUTPUT_FILE="$SCRIPT_DIR/cpu_hogger.csv"

start_ts=$(date +%s.%N)

./bin/serverledge-cli invoke -f cpu_hogger -p 'duration:180' -p 'memory:800'

end_ts=$(date +%s.%N)

if [[ ! -s "$OUTPUT_FILE" ]]; then
printf "start_ts,end_ts\n" >> "$OUTPUT_FILE"
fi

printf "%s,%s\n" "$start_ts" "$end_ts" >> "$OUTPUT_FILE"



echo "Done"
Binary file added examples/experiments/cpu_hogger.tar
Binary file not shown.
14 changes: 14 additions & 0 deletions examples/experiments/lb-config-MAB.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

registry:
area: "cloud-region"
udp.port: 9877

lb:
replicas: 128
mode: "MAB"
refresh_interval: 30

mab.policy: "LinUCB"

etcd:
address: "127.0.0.1:2379"
13 changes: 13 additions & 0 deletions examples/experiments/lb-config-RR.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

registry:
area: "cloud-region"
udp.port: 9877

lb:
replicas: 128
mode: "RoundRobin"
refresh_interval: 30


etcd:
address: "127.0.0.1:2379"
61 changes: 61 additions & 0 deletions examples/experiments/linpack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import time
import random


MATRIX_SIZE = 400

def gaussian_elimination(A, B):

n = len(A)
M = [A[i][:] + [B[i]] for i in range(n)]

for i in range(n):
pivot = M[i][i]
if pivot == 0: pivot = 1.0e-10

for j in range(i + 1, n):
factor = M[j][i] / pivot
for k in range(i, n + 1):
M[j][k] -= factor * M[i][k]

x = [0.0] * n
for i in range(n - 1, -1, -1):
sum_ax = sum(M[i][j] * x[j] for j in range(i + 1, n))
x[i] = (M[i][n] - sum_ax) / M[i][i]

return x

def handler(params, context):
n = MATRIX_SIZE

ops = (2.0 * n * n * n) / 3.0 + (2.0 * n * n)

A = []
for _ in range(n):
row = [(random.random() - 0.5) for _ in range(n)]
A.append(row)

B = []
for row in A:
B.append(sum(row))

start = time.time()

x = gaussian_elimination(A, B)

duration = time.time() - start

if duration <= 0:
duration = 0.000001

mflops = (ops * 1e-6 / duration)

validity_check = abs(x[0] - 1.0) < 1e-4

return {
"function": "linpack_pure",
"matrix_size": n,
"mflops": mflops,
"latency_seconds": duration,
"valid": validity_check
}
Loading