Remove flash-bench, docs, stray .class files; rewrite README for library
- Remove flash-bench module from git and root pom.xml (kept locally) - Remove docs/ directory (lifecycle markdown files) - Remove stray compiled fpr-core .class files tracked by mistake - Rewrite README.md: concise library overview, quick-start, handler styles, Maven dependency — no wrk/benchmarking content Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
9a30c5ab16
commit
5f0681a922
@@ -1,31 +1,83 @@
|
||||
# Flash Benchmarking Module
|
||||
# Flash
|
||||
|
||||
This module is designed for high-concurrency benchmarks using `wrk`.
|
||||
A high-performance HTTP/1.1 server library for Java 21+, built for low-latency workloads.
|
||||
|
||||
## Features
|
||||
|
||||
- **Virtual threads** — one virtual thread per connection via `Executors.newVirtualThreadPerTaskExecutor()`
|
||||
- **Zero-allocation hot path** — header buffer reused across keep-alive requests; `ByteView` slices avoid copies
|
||||
- **Fast routing** — `fpr-core` compiles routes into a byte-level finite automaton at first request; path params via `PathParams`
|
||||
- **Two-tier router** — mounted sub-routers matched by longest prefix, then `FastPathRouterImpl` fallback
|
||||
- **Middleware chain** — composable `Middleware` lambdas fused at registration time (no per-request allocation)
|
||||
- **Chunked transfer** — `ChunkedInputStream` de-chunks on the fly, keeps socket positioned for pipelining
|
||||
- **Request body** — `bytes()` for full materialization or `stream()` for zero-copy streaming
|
||||
|
||||
## Requirements
|
||||
|
||||
## Prerequisite
|
||||
- Java 21+
|
||||
- `wrk` installed (`sudo apt install wrk` on Linux/WSL)
|
||||
- Maven 3.8+
|
||||
|
||||
## Running the benchmarks
|
||||
## Build
|
||||
|
||||
1. **Build the project** (from the root directory):
|
||||
```bash
|
||||
mvn clean package -DskipTests
|
||||
```
|
||||
|
||||
2. **Start the benchmark server**:
|
||||
```bash
|
||||
java -jar flash-bench/target/flash-bench-1.0-SNAPSHOT.jar
|
||||
```
|
||||
|
||||
3. **Execute the benchmark suite** (from a new terminal):
|
||||
```bash
|
||||
cd flash-bench
|
||||
./benchmark.sh
|
||||
```
|
||||
|
||||
### Advanced: Random IDs Benchmarking
|
||||
To test the speed of parameter extraction across millions of unique IDs:
|
||||
```bash
|
||||
wrk -t12 -c500 -d30s -s pipeline.lua http://127.0.0.1:8080
|
||||
mvn clean package -DskipTests
|
||||
```
|
||||
|
||||
## Quick start
|
||||
|
||||
```java
|
||||
HttpServer server = new HttpServer(
|
||||
HttpServerConfiguration.builder().port(8080).build()
|
||||
);
|
||||
|
||||
server.get("/hello", (req, res) -> "Hello, world!");
|
||||
|
||||
server.register(new MyHandler()); // @Route(path="/...", method=GET)
|
||||
|
||||
server.start().thenRun(() -> System.out.println("Listening on :8080"));
|
||||
```
|
||||
|
||||
## Handler styles
|
||||
|
||||
**Lambda:**
|
||||
```java
|
||||
server.get("/ping", (req, res) -> "pong");
|
||||
```
|
||||
|
||||
**Class-based (`@Route`):**
|
||||
```java
|
||||
@Route(path = "/users/{id}", method = HttpMethod.GET)
|
||||
public class GetUser extends RequestHandler {
|
||||
@Override
|
||||
public Object handle(Request req, Response res) {
|
||||
String id = req.pathParam("id");
|
||||
return "{\"id\":\"" + id + "\"}";
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Middleware:**
|
||||
```java
|
||||
Middleware cors = next -> (req, res) -> {
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
return next.handle(req, res);
|
||||
};
|
||||
server.register(new GetUser(), cors);
|
||||
```
|
||||
|
||||
## Maven dependency
|
||||
|
||||
```xml
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>relism-releases</id>
|
||||
<url>https://maven.relism.dev/releases</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.relism</groupId>
|
||||
<artifactId>flash</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user