Skip to content

Comments

chopin: simplify benchmark to JSON and plaintext only#10789

Merged
msmith-techempower merged 10 commits intoTechEmpower:masterfrom
kowito:master
Feb 23, 2026
Merged

chopin: simplify benchmark to JSON and plaintext only#10789
msmith-techempower merged 10 commits intoTechEmpower:masterfrom
kowito:master

Conversation

@kowito
Copy link
Contributor

@kowito kowito commented Feb 19, 2026

Add Chopin Framework Benchmark

Overview

Adds a benchmark implementation for Chopin v0.3.3 web framework to TFB.

Implementation

  • Endpoints: /json and /plaintext using Chopin's FastRoute zero-allocation router
  • Runtime: Tokio with SO_REUSEPORT for multi-core parallelism
  • Dependencies:
    • chopin-core v0.2.1 (with perf feature)
    • axum (HTTP layer)
    • tokio (async runtime)
    • No ORM, DB, or template dependencies
  • Build: Multi-stage Dockerfile with LTO optimization, ~12MB distroless image

Design

Focuses on static response endpoints (FastRoute) rather than full CRUD because:

  1. FastRoute is Chopin's core optimization (zero-allocation)
  2. Provides clear performance baseline without DB complexity
  3. Aligns with framework's documented use case for "benchmark endpoints"

Files

frameworks/Rust/chopin/
├── benchmark/src/main.rs
├── benchmark/Cargo.toml
├── Cargo.toml (workspace)
├── chopin.dockerfile
├── benchmark_config.json
└── README.md

- Remove all database-related handlers (/db, /queries, /fortunes, /updates, /cached-queries)
- Use FastRoute zero-allocation endpoints for /json and /plaintext only
- Remove DB dependencies: sea-orm, yarte, rand, serde, bytes
- Remove template files and common helpers
- Update config to disable database
- Remove config.toml (superseded by benchmark_config.json)

Follows Chopin tutorial: FastRoute is optimized for static endpoints (~35ns per request).
Result: +5-16% JSON throughput, +13-23% plaintext throughput vs Axum.
@joanhey
Copy link
Contributor

joanhey commented Feb 19, 2026

Please add yourself to the maintainers in the benchmark_config.json.

So with any change or marked as broken, you will be notified.

Example:

{
"framework": "quarkus",
"maintainers": ["franz1981", "Sanne", "geoand"],
"tests": [
{
"default": {

…per TFB spec

- Update chopin-core to latest (0.3.4)
- Add serde/serde_json dependencies
- Implement /json handler with per-request serialization (required by TFB)
- Keep /plaintext as FastRoute (allowed by TFB plaintext spec)
- Comply with TFB JSON Serialization test requirement xiv:
  "The serialization to JSON must not be cached; the computational effort
   to serialize an object to JSON must occur within the scope of handling each request."
@joanhey
Copy link
Contributor

joanhey commented Feb 19, 2026

What changed now, than FastRoute don't cache ??

@joanhey
Copy link
Contributor

joanhey commented Feb 19, 2026

Please don't use the time and energy from other people, if you later change it again the FastRoute !!!

@kowito
Copy link
Contributor Author

kowito commented Feb 19, 2026

Please don't use the time and energy from other people, if you later change it again the FastRoute !!!

The original idea behind designing fastroute was to implement a health check without loading any middleware, as well as to serve static files, in order to reduce the system load. Another benefit is that it allows us to isolate certain APIs that need to be extremely lightweight. That's why we kept the option to enable cache headers if needed.

I apologize for the multiple revisions; I got a bit confused with how the plaintext caching was handled.

@kowito
Copy link
Contributor Author

kowito commented Feb 20, 2026

What changed now, than FastRoute don't cache ??

Please don't use the time and energy from other people, if you later change it again the FastRoute !!!

No, FastRoute does not cache routes by default.

@msmith-techempower msmith-techempower merged commit 2ea1e55 into TechEmpower:master Feb 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants