Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.
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
2 changes: 1 addition & 1 deletion frameworks/Dart/dart3/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.dart_tool/
*.lock

!bin
31 changes: 20 additions & 11 deletions frameworks/Dart/dart3/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
# Dart 3 Benchmarking Test

## Test Type Implementation Source Code

- [JSON](server.dart)
- [PLAINTEXT](server.dart)

## Important Libraries

The tests were run with:

- [Dart v3.10.8](https://dart.dev/)
- [Dart v3.11.0](https://dart.dev/)

## Benchmark Variants

### Native

Minimal implementation with the smallest resource footprint.
Supports basic horizontal scaling via [Isolates](https://dart.dev/language/isolates) and socket sharing.
([source code](https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/Dart/dart3/dart_native))

Test URLs:

## Test URLs
- JSON: `http://localhost:8080/json`
- PLAINTEXT: `http://localhost:8080/plaintext`

### JSON
### AOT

`http://localhost:8080/json`
Performance-oriented AOT implementation for superior horizontal scaling.
Achieves lowest latency and higher throughput with a slightly larger footprint.
([source code](https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/Dart/dart3/dart_aot))

### PLAINTEXT
Test URLs:

`http://localhost:8080/plaintext`
- JSON: `http://localhost:8080/json`
- PLAINTEXT: `http://localhost:8080/plaintext`
13 changes: 1 addition & 12 deletions frameworks/Dart/dart3/benchmark_config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"framework": "dart3",
"maintainers": ["iapicca"],
"tests": [{
"default": {
"display_name": "dart3_native",
Expand All @@ -24,18 +25,6 @@
"language": "Dart",
"os": "Linux",
"database_os": "Linux"
},
"hybrid": {
"display_name": "dart3_hybrid",
"json_url": "/json",
"plaintext_url": "/plaintext",
"port": 8080,
"approach": "Stripped",
"classification": "Platform",
"database": "None",
"language": "Dart",
"os": "Linux",
"database_os": "Linux"
}
}]
}
6 changes: 2 additions & 4 deletions frameworks/Dart/dart3/dart3-aot.dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

FROM dart:3.10.8 AS build
FROM dart:3.11.0 AS build
WORKDIR /app

# Define the build-time argument (Default to 8)
ARG MAX_ISOLATES=8

COPY pubspec.yaml .
COPY bin bin
COPY dart_native/bin/ bin/

RUN dart compile aot-snapshot bin/server.dart \
--define=MAX_ISOLATES=${MAX_ISOLATES} \
Expand All @@ -20,5 +19,4 @@ COPY --from=build /app/server.aot /app/server.aot

EXPOSE 8080

# Distroless requires absolute paths
ENTRYPOINT ["/usr/lib/dart/bin/dartaotruntime", "/app/server.aot"]
34 changes: 0 additions & 34 deletions frameworks/Dart/dart3/dart3-hybrid.dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions frameworks/Dart/dart3/dart3.dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

FROM dart:3.10.8 AS build
FROM dart:3.11.0 AS build
WORKDIR /app

COPY pubspec.yaml .
COPY bin bin
COPY dart_native/bin/ bin/

RUN dart compile exe bin/server.dart -o server

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:convert';
import 'dart:io';
import 'dart:isolate';
import 'dart:math' show min;
import 'package:args/args.dart' show ArgParser;

/// Environment declarations are evaluated at compile-time. Use 'const' to
/// ensure values are baked into AOT/Native binaries for the benchmark.
Expand All @@ -14,49 +13,54 @@ import 'package:args/args.dart' show ArgParser;
/// but most ahead-of-time compiled platforms will not have this information."
const _maxIsolatesfromEnvironment = int.fromEnvironment('MAX_ISOLATES');

/// The fixed TCP port used by the server.
/// Defined here for visibility and ease of configuration.
const _defaultPort = 8080;

/// A reusable instance of the UTF-8 JSON encoder to efficiently
/// transform Dart objects into byte arrays for HTTP responses.
final _jsonEncoder = JsonUtf8Encoder();

/// Internal token used to notify newly spawned processes that they
/// belong to a secondary "worker group".
const workerGroupTag = '--workerGroup';

void main(List<String> args) {
/// Defines local isolate quota, using MAX_ISOLATES if provided.
/// Falls back to total available cores while respecting hardware limits.
var maxIsolates = _maxIsolatesfromEnvironment > 0
? min(_maxIsolatesfromEnvironment, Platform.numberOfProcessors)
: Platform.numberOfProcessors;

/// Triggers process-level horizontal scaling when running in AOT.
if (Platform.script.toFilePath().endsWith('.aot')) {
/// Internal token used to notify newly spawned processes that they
/// belong to a secondary "worker group".
const workerGroupTag = '--workerGroup';

/// Determine if this process instance was initialized as a worker group.
final isWorkerGroup = args.contains(workerGroupTag);
/// Determine if this process instance was initialized as a worker group.
final isWorkerGroup = args.contains(workerGroupTag);

if (isWorkerGroup) {
/// Sanitize the argument list to ensure the internal token does not
/// interfere with application-level argument parsing.
args.removeAt(args.indexOf(workerGroupTag));
}
/// Prevents recursive spawning
/// by ensuring only the primary process can spawn worker groups
else {
/// Calculate the number of secondary worker groups required
/// to fully utilize the available hardware capacity.
///
/// Each group serves as a container for multiple isolates,
/// helping to bypass internal VM scaling bottlenecks.
final workerGroups = Platform.numberOfProcessors ~/ maxIsolates - 1;

/// Bootstraps independent worker processes via AOT snapshots.
/// Each process initializes its own Isolate Group.
for (var i = 0; i < workerGroups; i++) {
/// [Platform.script] identifies the AOT snapshot or executable.
/// [Isolate.spawnUri] spawns a new process group via [main()].
Isolate.spawnUri(Platform.script, [...args, workerGroupTag], null);
}

/// Updates local isolate limits, assigning the primary group
/// the remaining cores after worker group allocation.
maxIsolates = Platform.numberOfProcessors - workerGroups * maxIsolates;
if (isWorkerGroup) {
/// Sanitize the argument list to ensure the internal token does not
/// interfere with application-level argument parsing.
args.removeAt(args.indexOf(workerGroupTag));
}
/// Prevents recursive spawning
/// by ensuring only the primary process can spawn worker groups
else {
/// Calculate the number of secondary worker groups required
/// to fully utilize the available hardware capacity.
///
/// Each group serves as a container for multiple isolates,
/// helping to bypass internal VM scaling bottlenecks.
final workerGroups = Platform.numberOfProcessors ~/ maxIsolates - 1;

/// Bootstraps independent worker processes via AOT snapshots.
/// Each process initializes its own Isolate Group.
for (var i = 0; i < workerGroups; i++) {
/// [Platform.script] identifies the AOT snapshot or executable.
/// [Isolate.spawnUri] spawns a new process group via [main()].
Isolate.spawnUri(Platform.script, [...args, workerGroupTag], null);
}

/// Updates local isolate limits, assigning the primary group
/// the remaining cores after worker group allocation.
maxIsolates = Platform.numberOfProcessors - workerGroups * maxIsolates;
}

/// Create an [Isolate] containing an [HttpServer]
Expand All @@ -74,14 +78,14 @@ void _startServer(List<String> args) async {
/// Binds the [HttpServer] on `0.0.0.0:8080`.
final server = await HttpServer.bind(
InternetAddress.anyIPv4,
_portParser(args, defaultPort: 8080),
_defaultPort,
shared: true,
);

server
..defaultResponseHeaders.clear()
/// Sets [HttpServer]'s [serverHeader].
..serverHeader = 'dart'
..serverHeader = 'dart_aot'
/// Handles [HttpRequest]'s from [HttpServer].
..listen(_handleRequest);
}
Expand Down Expand Up @@ -142,18 +146,3 @@ void _plaintextTest(HttpRequest request) => _sendText(
request,
'Hello, World!',
);

final _jsonEncoder = JsonUtf8Encoder();

int _portParser(
List<String> args, {
required int defaultPort,
portTag = 'port',
}) {
final parser = ArgParser()
..addOption(
portTag,
defaultsTo: '$defaultPort',
);
return int.tryParse(parser.parse(args)[portTag]) ?? defaultPort;
}
41 changes: 0 additions & 41 deletions frameworks/Dart/dart3/dart_hybrid/run.sh

This file was deleted.

17 changes: 0 additions & 17 deletions frameworks/Dart/dart3/dart_hybrid/traefik.yaml

This file was deleted.

19 changes: 0 additions & 19 deletions frameworks/Dart/dart3/dart_hybrid/traefik_dynamic.yaml

This file was deleted.

Loading
Loading