Skip to content
Closed
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
8 changes: 8 additions & 0 deletions .github/workflows/regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ jobs:
language: java
version: "21"
architecture: "arm64"
- platform: aws
language: dotnet
version: "10"
architecture: "x64"
- platform: aws
language: dotnet
version: "10"
architecture: "arm64"
- platform: gcp
language: python
version: "3.11"
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### Features

* Object storage for Java and .NET on AWS: `Storage.java` (AWS SDK v2) and `Storage.cs` (AWSSDK.S3) implement the interface of the Python wrapper's `storage` class. Both are added only to benchmarks declaring the `storage` module, through the new `module_files` and `module_packages` entries in `configs/systems.json`, so benchmarks without storage keep their package size and cold start.

* Cold start enforcement for the local deployment: SeBS replaces the function container, and the local function servers report the first invocation of a container as cold. Requires the updated local run images.

* [RustFS](https://github.com/rustfs/rustfs) is the new default S3-compatible object storage for local and OpenWhisk deployments. Minio is deprecated and kept for reproducibility (`configs/storage-minio.json`). The self-hosted object storage implementation is now shared between backends.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/000.microbenchmarks/010.sleep/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"timeout": 120,
"memory": 128,
"languages": ["python", "nodejs", "java", "cpp"],
"languages": ["python", "nodejs", "java", "cpp", "dotnet"],
"modules": [],
"cpp_dependencies": []
}
20 changes: 20 additions & 0 deletions benchmarks/000.microbenchmarks/010.sleep/dotnet/Function.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2020-2025 ETH Zurich and the SeBS authors. All rights reserved.
using System;
using System.Diagnostics;
using System.Text.Json.Nodes;
using System.Threading;

namespace Benchmark;

public class Function
{
public JsonObject Handler(JsonObject input)
{
double seconds = input["sleep"]?.GetValue<double>()
?? throw new ArgumentException("expected a number in 'sleep'");

var stopwatch = Stopwatch.StartNew();
Thread.Sleep(TimeSpan.FromSeconds(seconds));
return new JsonObject { ["result"] = stopwatch.Elapsed.TotalSeconds };
}
}
17 changes: 17 additions & 0 deletions benchmarks/000.microbenchmarks/010.sleep/dotnet/function.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!-- DOTNET_VERSION is set by the build image. -->
<TargetFramework>net$(DOTNET_VERSION).0</TargetFramework>
<!-- Part of the platform handler strings. -->
<AssemblyName>function</AssemblyName>
<Nullable>enable</Nullable>
<!-- Required by the runtime; not generated for libraries by default. -->
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>

<ItemGroup>
<!-- PLATFORM_DEPENDENCIES -->
</ItemGroup>

</Project>
90 changes: 90 additions & 0 deletions benchmarks/wrappers/aws/dotnet/Handler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Copyright 2020-2025 ETH Zurich and the SeBS authors. All rights reserved.

// The benchmark must define Benchmark.Function with JsonObject Handler(JsonObject input).

using System;
using System.Globalization;
using System.IO;
using System.Text;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Nodes;
using Amazon.Lambda.Core;

namespace ServerlessBench;

public class Handler
{
private const string ColdStartMarker = "/tmp/cold_run";

// Skip HTML-safe escaping, matching the other wrappers' output.
private static readonly JsonSerializerOptions JsonOptions =
new() { Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping };

public Stream HandleRequest(Stream input, ILambdaContext context)
{
JsonObject evt = ParseEvent(input);

DateTimeOffset begin = DateTimeOffset.UtcNow;
JsonObject result = new Benchmark.Function().Handler(evt);
DateTimeOffset end = DateTimeOffset.UtcNow;

(bool isCold, string containerId) = CheckColdStart();

var body = new JsonObject
{
["begin"] = FormatTimestamp(begin),
["end"] = FormatTimestamp(end),
["results_time"] = 0,
["is_cold"] = isCold,
["result"] = result,
["request_id"] = context.AwsRequestId,
["cold_start_var"] = Environment.GetEnvironmentVariable("cold_start") ?? "",
["container_id"] = containerId,
};
var response = new JsonObject
{
["statusCode"] = 200,
["body"] = body.ToJsonString(JsonOptions),
};
return new MemoryStream(Encoding.UTF8.GetBytes(response.ToJsonString(JsonOptions)));
}

// HTTP triggers wrap the input in a JSON string under "body".
private static JsonObject ParseEvent(Stream input)
{
JsonObject evt = JsonNode.Parse(input) as JsonObject ?? new JsonObject();
if (evt["body"] is JsonValue body && body.TryGetValue(out string? text)
&& JsonNode.Parse(text) is JsonObject parsed)
{
return parsed;
}
return evt;
}

private static (bool, string) CheckColdStart()
{
if (File.Exists(ColdStartMarker))
{
return (false, File.ReadAllText(ColdStartMarker));
}
string containerId = Guid.NewGuid().ToString("N").Substring(0, 8);
try
{
File.WriteAllText(ColdStartMarker, containerId);
}
catch (IOException)
{
// Best effort.
}
return (true, containerId);
}

// seconds.microseconds, like the other wrappers.
private static string FormatTimestamp(DateTimeOffset ts)
{
long micros = (ts.UtcTicks - DateTimeOffset.UnixEpoch.UtcTicks) / 10;
return string.Format(
CultureInfo.InvariantCulture, "{0}.{1:D6}", micros / 1_000_000, micros % 1_000_000);
}
}
111 changes: 111 additions & 0 deletions benchmarks/wrappers/aws/dotnet/Storage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// Copyright 2020-2025 ETH Zurich and the SeBS authors. All rights reserved.

// Object storage, the counterpart of the Python wrapper's `storage` class.
// Added to the deployment package only for benchmarks declaring the `storage` module,
// because the SDK dominates the package size and the cold start.

using System;
using System.Collections.Generic;
using System.IO;
using Amazon.S3;
using Amazon.S3.Model;
using Amazon.S3.Transfer;

namespace ServerlessBench;

public sealed class Storage
{
private static Storage? instance;

private readonly IAmazonS3 client;
private readonly TransferUtility transfer;

private Storage()
{
this.client = new AmazonS3Client();
this.transfer = new TransferUtility(this.client);
}

// Created lazily, like the Python wrapper, so that the SDK's start-up cost falls into the
// first invocation rather than the platform's initialization phase.
public static Storage GetInstance() => instance ??= new Storage();

// Insert a random suffix before the file extension, as the other wrappers do.
public static string UniqueName(string name)
{
int separator = name.LastIndexOf('/');
int dot = name.LastIndexOf('.');
string file = name;
string extension = "";
if (dot > separator)
{
file = name.Substring(0, dot);
extension = name.Substring(dot);
}
string random = Guid.NewGuid().ToString("N").Substring(0, 8);
return $"{file}.{random}{extension}";
}

// Uploads a local file under a randomized key and returns that key.
public string Upload(string bucket, string file, string filepath)
{
string keyName = UniqueName(file);
this.transfer.UploadAsync(filepath, bucket, keyName).GetAwaiter().GetResult();
return keyName;
}

// Downloads an object to a local file, creating parent directories as needed.
public void Download(string bucket, string file, string filepath)
{
string? directory = Path.GetDirectoryName(filepath);
if (!string.IsNullOrEmpty(directory))
{
Directory.CreateDirectory(directory);
}
this.transfer.DownloadAsync(filepath, bucket, file).GetAwaiter().GetResult();
}

// Downloads every object with the given prefix, recreating the key structure under a path.
public void DownloadDirectory(string bucket, string prefix, string path)
{
var request = new ListObjectsV2Request { BucketName = bucket, Prefix = prefix };
bool found = false;
do
{
ListObjectsV2Response objects =
this.client.ListObjectsV2Async(request).GetAwaiter().GetResult();
foreach (S3Object entry in objects.S3Objects ?? new List<S3Object>())
{
found = true;
Download(bucket, entry.Key, Path.Combine(path, entry.Key));
}
request.ContinuationToken = objects.NextContinuationToken;
}
while (request.ContinuationToken != null);

if (!found)
{
throw new IOException(
$"No objects found in bucket '{bucket}' with prefix '{prefix}'");
}
}

// Uploads in-memory data under a randomized key and returns that key.
public string UploadStream(string bucket, string file, byte[] data)
{
string keyName = UniqueName(file);
using var stream = new MemoryStream(data);
this.transfer.UploadAsync(stream, bucket, keyName).GetAwaiter().GetResult();
return keyName;
}

// Downloads an object into memory.
public byte[] DownloadStream(string bucket, string file)
{
using Stream stream =
this.transfer.OpenStreamAsync(bucket, file).GetAwaiter().GetResult();
using var buffer = new MemoryStream();
stream.CopyTo(buffer);
return buffer.ToArray();
}
}
Loading