Skip to content

Commit c5ca350

Browse files
committed
results update
1 parent 4da8c74 commit c5ca350

184 files changed

Lines changed: 40003 additions & 15262 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

frameworks/actix/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ rustls-pemfile = "2"
1111
serde = { version = "1", features = ["derive"] }
1212
serde_json = "1"
1313
num_cpus = "1"
14+
rusqlite = { version = "0.31", features = ["bundled"] }
1415

1516
[profile.release]
1617
opt-level = 3

frameworks/actix/meta.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"display_name": "actix",
33
"language": "Rust",
4-
"type": "realistic",
4+
"type": "framework",
55
"engine": "actix",
66
"description": "Actix-web 4 with rustls for HTTP/2 support, compiled with -O3 and thin LTO.",
77
"repo": "https://github.com/actix/actix-web",
@@ -13,6 +13,8 @@
1313
"limited-conn",
1414
"json",
1515
"upload",
16+
"compression",
17+
"mixed",
1618
"baseline-h2",
1719
"static-h2"
1820
]

frameworks/actix/src/main.rs

Lines changed: 53 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
use actix_web::http::header::{ContentType, HeaderValue, SERVER};
22
use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer};
3+
use rusqlite::Connection;
34
use rustls::ServerConfig;
45
use serde::{Deserialize, Serialize};
56
use std::collections::HashMap;
67
use std::io;
7-
use std::sync::Arc;
8+
use std::sync::{Arc, Mutex};
89

910
static SERVER_HDR: HeaderValue = HeaderValue::from_static("actix");
1011

@@ -62,6 +63,8 @@ struct AppState {
6263
static_files: HashMap<String, StaticFile>,
6364
}
6465

66+
struct WorkerDb(Mutex<Connection>);
67+
6568
fn load_dataset() -> Vec<DatasetItem> {
6669
let path = std::env::var("DATASET_PATH").unwrap_or_else(|_| "/data/dataset.json".to_string());
6770
match std::fs::read_to_string(&path) {
@@ -157,41 +160,11 @@ async fn baseline11_get(req: HttpRequest) -> HttpResponse {
157160
.body(sum.to_string())
158161
}
159162

160-
fn crc32_compute(data: &[u8]) -> u32 {
161-
static TABLE: std::sync::OnceLock<[[u32; 256]; 8]> = std::sync::OnceLock::new();
162-
let t = TABLE.get_or_init(|| {
163-
let mut t = [[0u32; 256]; 8];
164-
for i in 0..256u32 {
165-
let mut c = i;
166-
for _ in 0..8 { c = if c & 1 != 0 { 0xEDB88320 ^ (c >> 1) } else { c >> 1 }; }
167-
t[0][i as usize] = c;
168-
}
169-
for i in 0..256 {
170-
for s in 1..8 { t[s][i] = (t[s-1][i] >> 8) ^ t[0][(t[s-1][i] & 0xFF) as usize]; }
171-
}
172-
t
173-
});
174-
let mut crc = 0xFFFFFFFFu32;
175-
let mut i = 0;
176-
while i + 8 <= data.len() {
177-
let a = u32::from_le_bytes([data[i], data[i+1], data[i+2], data[i+3]]) ^ crc;
178-
let b = u32::from_le_bytes([data[i+4], data[i+5], data[i+6], data[i+7]]);
179-
crc = t[7][(a & 0xFF) as usize] ^ t[6][((a >> 8) & 0xFF) as usize]
180-
^ t[5][((a >> 16) & 0xFF) as usize] ^ t[4][(a >> 24) as usize]
181-
^ t[3][(b & 0xFF) as usize] ^ t[2][((b >> 8) & 0xFF) as usize]
182-
^ t[1][((b >> 16) & 0xFF) as usize] ^ t[0][(b >> 24) as usize];
183-
i += 8;
184-
}
185-
while i < data.len() { crc = (crc >> 8) ^ t[0][((crc ^ data[i] as u32) & 0xFF) as usize]; i += 1; }
186-
crc ^ 0xFFFFFFFF
187-
}
188-
189163
async fn upload(body: web::Bytes) -> HttpResponse {
190-
let crc = crc32_compute(&body);
191164
HttpResponse::Ok()
192165
.insert_header((SERVER, SERVER_HDR.clone()))
193166
.content_type(ContentType::plaintext())
194-
.body(format!("{:08x}", crc))
167+
.body(body.len().to_string())
195168
}
196169

197170
async fn baseline11_post(req: HttpRequest, body: web::Bytes) -> HttpResponse {
@@ -253,6 +226,43 @@ async fn compression(state: web::Data<Arc<AppState>>) -> HttpResponse {
253226
.body(state.json_large_cache.clone())
254227
}
255228

229+
async fn db_endpoint(req: HttpRequest, db: web::Data<WorkerDb>) -> HttpResponse {
230+
let min: f64 = req.uri().query().and_then(|q| {
231+
q.split('&').find_map(|p| p.strip_prefix("min=").and_then(|v| v.parse().ok()))
232+
}).unwrap_or(10.0);
233+
let max: f64 = req.uri().query().and_then(|q| {
234+
q.split('&').find_map(|p| p.strip_prefix("max=").and_then(|v| v.parse().ok()))
235+
}).unwrap_or(50.0);
236+
let conn = db.0.lock().unwrap();
237+
let mut stmt = conn.prepare_cached(
238+
"SELECT id, name, category, price, quantity, active, tags, rating_score, rating_count FROM items WHERE price BETWEEN ?1 AND ?2 LIMIT 50"
239+
).unwrap();
240+
let rows = stmt.query_map(rusqlite::params![min, max], |row| {
241+
Ok(serde_json::json!({
242+
"id": row.get::<_, i64>(0)?,
243+
"name": row.get::<_, String>(1)?,
244+
"category": row.get::<_, String>(2)?,
245+
"price": row.get::<_, f64>(3)?,
246+
"quantity": row.get::<_, i64>(4)?,
247+
"active": row.get::<_, i64>(5)? == 1,
248+
"tags": serde_json::from_str::<serde_json::Value>(&row.get::<_, String>(6)?).unwrap_or_default(),
249+
"rating": serde_json::json!({
250+
"score": row.get::<_, f64>(7)?,
251+
"count": row.get::<_, i64>(8)?
252+
})
253+
}))
254+
});
255+
let items: Vec<serde_json::Value> = match rows {
256+
Ok(mapped) => mapped.filter_map(|r| r.ok()).collect(),
257+
Err(_) => Vec::new(),
258+
};
259+
let result = serde_json::json!({"items": items, "count": items.len()});
260+
HttpResponse::Ok()
261+
.insert_header((SERVER, SERVER_HDR.clone()))
262+
.content_type(ContentType::json())
263+
.body(result.to_string())
264+
}
265+
256266
async fn static_file(
257267
state: web::Data<Arc<AppState>>,
258268
path: web::Path<String>,
@@ -307,16 +317,27 @@ async fn main() -> io::Result<()> {
307317
let mut server = HttpServer::new({
308318
let state = state.clone();
309319
move || {
320+
let worker_db = Connection::open_with_flags(
321+
"/data/benchmark.db",
322+
rusqlite::OpenFlags::SQLITE_OPEN_READ_ONLY,
323+
)
324+
.map(|conn| {
325+
conn.execute_batch("PRAGMA mmap_size=268435456").ok();
326+
WorkerDb(Mutex::new(conn))
327+
})
328+
.expect("Failed to open database");
310329
App::new()
311330
.wrap(actix_web::middleware::Compress::default())
312331
.app_data(web::Data::new(state.clone()))
332+
.app_data(web::Data::new(worker_db))
313333
.app_data(web::PayloadConfig::new(25 * 1024 * 1024))
314334
.route("/pipeline", web::get().to(pipeline))
315335
.route("/baseline11", web::get().to(baseline11_get))
316336
.route("/baseline11", web::post().to(baseline11_post))
317337
.route("/baseline2", web::get().to(baseline2))
318338
.route("/json", web::get().to(json_endpoint))
319339
.route("/compression", web::get().to(compression))
340+
.route("/db", web::get().to(db_endpoint))
320341
.route("/upload", web::post().to(upload))
321342
.route("/static/{filename}", web::get().to(static_file))
322343
}

frameworks/aspnet-minimal/Program.cs

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,7 @@
197197
{
198198
using var ms = new MemoryStream();
199199
await req.Body.CopyToAsync(ms);
200-
uint crc = Crc32Helper.Compute(ms.GetBuffer().AsSpan(0, (int)ms.Length));
201-
return Results.Text(crc.ToString("x8"));
200+
return Results.Text(ms.Length.ToString());
202201
});
203202

204203
app.MapGet("/json", () =>
@@ -278,40 +277,3 @@ class RatingInfo
278277
public double Score { get; set; }
279278
public int Count { get; set; }
280279
}
281-
282-
static class Crc32Helper
283-
{
284-
private static readonly uint[][] T = new uint[8][];
285-
static Crc32Helper()
286-
{
287-
for (int s = 0; s < 8; s++) T[s] = new uint[256];
288-
for (uint i = 0; i < 256; i++)
289-
{
290-
uint c = i;
291-
for (int j = 0; j < 8; j++)
292-
c = (c >> 1) ^ (0xEDB88320u & (0u - (c & 1u)));
293-
T[0][i] = c;
294-
}
295-
for (uint i = 0; i < 256; i++)
296-
for (int s = 1; s < 8; s++)
297-
T[s][i] = (T[s-1][i] >> 8) ^ T[0][T[s-1][i] & 0xFF];
298-
}
299-
public static uint Compute(ReadOnlySpan<byte> data)
300-
{
301-
uint crc = 0xFFFFFFFF;
302-
int i = 0;
303-
while (i + 8 <= data.Length)
304-
{
305-
uint a = (uint)(data[i] | (data[i+1] << 8) | (data[i+2] << 16) | (data[i+3] << 24)) ^ crc;
306-
uint b = (uint)(data[i+4] | (data[i+5] << 8) | (data[i+6] << 16) | (data[i+7] << 24));
307-
crc = T[7][a & 0xFF] ^ T[6][(a >> 8) & 0xFF]
308-
^ T[5][(a >> 16) & 0xFF] ^ T[4][a >> 24]
309-
^ T[3][b & 0xFF] ^ T[2][(b >> 8) & 0xFF]
310-
^ T[1][(b >> 16) & 0xFF] ^ T[0][b >> 24];
311-
i += 8;
312-
}
313-
while (i < data.Length)
314-
crc = (crc >> 8) ^ T[0][(crc ^ data[i++]) & 0xFF];
315-
return crc ^ 0xFFFFFFFF;
316-
}
317-
}

frameworks/aspnet-minimal/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"display_name": "aspnet-minimal",
33
"language": "C#",
4-
"type": "realistic",
4+
"type": "framework",
55
"engine": "Kestrel",
66
"description": "Minimal ASP.NET Core server using .NET 10 preview with Kestrel and minimal API routing.",
77
"repo": "https://github.com/dotnet/aspnetcore",

frameworks/bun/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"display_name": "bun",
33
"language": "TS",
4-
"type": "realistic",
4+
"type": "framework",
55
"engine": "JSC",
66
"description": "Bun's built-in HTTP server using JavaScriptCore engine with multi-core clustering.",
77
"repo": "https://github.com/oven-sh/bun",

frameworks/bun/server.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ function handleRequest(req: Request): Response | Promise<Response> {
144144

145145
if (path === "/upload" && req.method === "POST") {
146146
return req.arrayBuffer().then((ab) => {
147-
const buf = Buffer.from(ab);
148-
const c = zlib.crc32(buf);
149-
return new Response((c >>> 0).toString(16).padStart(8, "0"), {
147+
return new Response(String(ab.byteLength), {
150148
headers: { "content-type": "text/plain" },
151149
});
152150
});

frameworks/caddy/handler.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"database/sql"
55
"encoding/json"
66
"fmt"
7-
"hash/crc32"
87
"io"
98
"math"
109
"net/http"
@@ -220,10 +219,9 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyht
220219
case "/upload":
221220
if r.Method == "POST" && r.Body != nil {
222221
body, _ := io.ReadAll(r.Body)
223-
checksum := crc32.ChecksumIEEE(body)
224222
w.Header().Set("Content-Type", "text/plain")
225223
w.Header().Set("Server", "caddy")
226-
fmt.Fprintf(w, "%08x", checksum)
224+
fmt.Fprintf(w, "%d", len(body))
227225
} else {
228226
http.Error(w, "POST required", 405)
229227
}

frameworks/caddy/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"display_name": "caddy",
33
"language": "Go",
4-
"type": "realistic",
4+
"type": "framework",
55
"engine": "caddy",
66
"description": "Caddy web server with a custom handler module for benchmark endpoints, native HTTP/2 support.",
77
"repo": "https://github.com/caddyserver/caddy",

frameworks/deno/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
FROM denoland/deno:2.2.2
2+
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl && rm -rf /var/lib/apt/lists/*
23
WORKDIR /app
34
COPY main.ts .
45
RUN deno cache main.ts
6+
RUN curl -fsSL -o /app/libsqlite3.so https://github.com/denodrivers/sqlite3/releases/download/0.12.0/libsqlite3.so
7+
ENV DENO_SQLITE_PATH=/app/libsqlite3.so
58
EXPOSE 8080
69
CMD ["deno", "serve", "--parallel", "--port", "8080", "--host", "0.0.0.0", "-A", "main.ts"]

0 commit comments

Comments
 (0)