Skip to content
Open
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
4 changes: 1 addition & 3 deletions frameworks/Dart/dart3/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
*.lock
!bin

2 changes: 1 addition & 1 deletion frameworks/Dart/dart3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

The tests were run with:

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

## Test URLs

Expand Down
52 changes: 24 additions & 28 deletions frameworks/Dart/dart3/benchmark_config.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
{
"framework": "dart3",
"tests": [
{
"default": {
"display_name": "dart3_native",
"json_url": "/json",
"plaintext_url": "/plaintext",
"port": 8080,
"approach": "Stripped",
"classification": "Platform",
"database": "None",
"language": "Dart",
"os": "Linux",
"database_os": "Linux"
}
"tests": [{
"default": {
"display_name": "dart3_native",
"json_url": "/json",
"plaintext_url": "/plaintext",
"port": 8080,
"approach": "Stripped",
"classification": "Platform",
"database": "None",
"language": "Dart",
"os": "Linux",
"database_os": "Linux"
},
{
"aot": {
"display_name": "dart3_aot",
"json_url": "/json",
"plaintext_url": "/plaintext",
"port": 8080,
"approach": "Stripped",
"classification": "Platform",
"database": "None",
"language": "Dart",
"os": "Linux",
"database_os": "Linux"
}
"aot": {
"display_name": "dart3_aot",
"json_url": "/json",
"plaintext_url": "/plaintext",
"port": 8080,
"approach": "Stripped",
"classification": "Platform",
"database": "None",
"language": "Dart",
"os": "Linux",
"database_os": "Linux"
}
]
}]
}
53 changes: 20 additions & 33 deletions frameworks/Dart/dart3/bin/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'dart:math' show min;
/// but most ahead-of-time compiled platforms will not have this information."
const _maxIsolatesfromEnvironment = int.fromEnvironment('MAX_ISOLATES');

void main(List<String> args) async {
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
Expand Down Expand Up @@ -49,7 +49,7 @@ void main(List<String> args) async {
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, [workerGroupTag, ...args], null);
Isolate.spawnUri(Platform.script, [...args, workerGroupTag], null);
}

/// Updates local isolate limits, assigning the primary group
Expand All @@ -61,54 +61,41 @@ void main(List<String> args) async {
/// Create an [Isolate] containing an [HttpServer]
/// for each processor after the first
for (var i = 1; i < maxIsolates; i++) {
await Isolate.spawn(_startServer, args);
Isolate.spawn(_startServer, args);
}

/// Create a [HttpServer] for the first processor
await _startServer(args);
_startServer(args);
}

/// Creates and setup a [HttpServer]
Future<void> _startServer(List<String> _) async {
void _startServer(List<String> args) async {
/// Binds the [HttpServer] on `0.0.0.0:8080`.
final server = await HttpServer.bind(
InternetAddress.anyIPv4,
8080,
shared: true,
);

/// Sets [HttpServer]'s [serverHeader].
server
..defaultResponseHeaders.clear()
..serverHeader = 'dart';

/// Handles [HttpRequest]'s from [HttpServer].
await for (final request in server) {
/// Asynchronously processes each request with an 8-second safety deadline
/// to prevent stalled connections from blocking the isolate event loop.
_handleRequest(request).timeout(
const Duration(seconds: 8),
onTimeout: () => _sendResponse(request, HttpStatus.internalServerError),
);
}
/// Sets [HttpServer]'s [serverHeader].
..serverHeader = 'dart'
/// Handles [HttpRequest]'s from [HttpServer].
..listen(_handleRequest);
}

/// Dispatches requests to specific test handlers. Wrapped in a try-catch
/// to ensure stable execution and guaranteed response delivery.
Future<void> _handleRequest(HttpRequest request) async {
try {
switch (request.uri.path) {
case '/json':
_jsonTest(request);
break;
case '/plaintext':
_plaintextTest(request);
break;
default:
_sendResponse(request, HttpStatus.notFound);
}
} catch (e) {
_sendResponse(request, HttpStatus.internalServerError);
/// Dispatches requests to specific handlers.
void _handleRequest(HttpRequest request) {
switch (request.uri.path) {
case '/json':
_jsonTest(request);
break;
case '/plaintext':
_plaintextTest(request);
break;
default:
_sendResponse(request, HttpStatus.notFound);
}
}

Expand Down
2 changes: 1 addition & 1 deletion frameworks/Dart/dart3/dart3-aot.dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

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

# Define the build-time argument (Default to 8)
Expand Down
24 changes: 5 additions & 19 deletions frameworks/Dart/dart3/dart3.dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@

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

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

COPY pubspec.yaml .
COPY bin bin

RUN dart compile exe bin/server.dart \
--define=MAX_ISOLATES=${MAX_ISOLATES} \
-o server

FROM busybox:glibc
WORKDIR /app

# Re-declare ARG 'MAX_ISOLATES' in the second stage to use it in ENV
ARG MAX_ISOLATES=8
ENV MAX_ISOLATES_PER_PROCESS=${MAX_ISOLATES}
RUN dart compile exe bin/server.dart -o server

FROM scratch
COPY --from=build /runtime/ /
COPY --from=build /app/server /app/server
COPY run.sh /bin/run.sh

RUN chmod +x /bin/run.sh
COPY --from=build /app/server /bin/server

EXPOSE 8080
CMD ["/bin/run.sh"]
ENTRYPOINT ["server"]
2 changes: 1 addition & 1 deletion frameworks/Dart/dart3/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: dartbenchmark
description: A benchmark of dart
environment:
sdk: ^3.10.7
sdk: ^3.10.8

dev_dependencies:
lints: ^6.0.0
18 changes: 0 additions & 18 deletions frameworks/Dart/dart3/run.sh

This file was deleted.

Loading