# FastJudge0 — Complete Machine-Readable Reference for AI Agents Repository: https://github.com/arbazkhan971/fastjudge0 License: MIT Protocol compatibility: Judge0 1.13.1 HTTP REST + Model Context Protocol (MCP 2024-11-05 Streamable HTTP & stdio) + A2A Agent Card ## 1. Overview & Performance FastJudge0 replaces Judge0's Ruby on Rails + Postgres + Resque queue pipeline with an async Rust (`tokio` + `axum`) orchestrator executing user code inside the exact same `judge0/judge0:1.13.1` compilers and Linux kernel `isolate --cg` sandboxes: - Compile-once + `/dev/shm` `OnceCell`-deduplicated artifact cache (never caches compilation timeouts). - Pre-warmed `isolate --cg` sandbox pool with in-RAM cleanup. - In-sandbox multi-case execution (`URLClassLoader(..., PlatformClassLoader)` + `System.exit` trap + locale/timezone/thread leak guard for Java; AST compile once + `os.fork()` per case for Python; clean `./a.out` / `db.sqlite` loop for C/C++/SQL), automatically falling back to per-case `isolate` on TLE/OOM/crash. Measured on AWS `c6a.4xlarge` (AMD EPYC 7R13, 16 vCPUs, Linux cgroup v1, 10-case batches): - Python 3.8 (0% cache, unique programs): **117,713 / min** (`p95 = 0.243s`) vs Stock Judge0 `1,567 / min` (**75.1x**) - Java 13 (0% cache, 100% unique): **7,843 / min** (`p95 = 3.67s`) vs Stock `387 / min` (**20.2x**) - Java 13 (40% template mix): **11,209 / min** (`p95 = 3.45s`) (**28.9x**) - C++ GCC 9.2 (0% cache, 100% unique): **13,221 / min** (`p95 = 2.07s`) vs Stock `756 / min` (**17.5x**) - Sustained mixed exam surge (51% Java / 44% Py / 5% C++): **19,729 / min** (`p50 = 0.607s`, `p95 = 2.269s`, `0` errors) - OS `SIGKILL` crash recovery: **`0.274s`** to `/healthz` 200 and **`1.131s`** to healthy Python+Java+C++ verdicts (vs `16.63s` and `16` orphaned jobs on Stock Judge0) ## 2. Discovery Endpoints (Unauthenticated) - `GET /healthz` -> `{"status":"ok","engine":"fastjudge0-rust"}` - `GET /llms.txt` -> compact LLM index - `GET /llms-full.txt` -> this complete document - `GET /openapi.yaml` -> OpenAPI 3.1.0 schema - `GET /.well-known/agent-card.json` -> A2A discovery card - `GET /.well-known/ai-plugin.json` -> AI plugin manifest ## 3. Native MCP Streamable HTTP (`POST /mcp`) Send standard JSON-RPC 2.0 requests directly to `POST /mcp` (`X-Auth-Token` header required only if `AUTHN_TOKEN` env var is set): Initialize: ```json {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05"}} ``` List tools: ```json {"jsonrpc":"2.0","id":2,"method":"tools/list"} ``` Execute single program (`execute_code`): ```json { "jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": { "name": "execute_code", "arguments": { "language_id": 71, "source_code": "print(int(input()) * 2)", "stdin": "21\n", "expected_output": "42\n" } } } ``` Execute unit-test suite (`execute_test_suite`): ```json { "jsonrpc": "2.0", "id": 4, "method": "tools/call", "params": { "name": "execute_test_suite", "arguments": { "language_id": 54, "source_code": "#include \nint main(){int x;std::cin>>x;std::cout<`, `BOX_ID_START=900` - `CACHE_DIR=/dev/shm/fastjudge0-cache`, `CACHE_MAX_ENTRIES=2048` - `BATCH_HARNESS_ENABLED=true` (set `false` for strict per-case `isolate` containers) - `TOKEN_TTL_SECS=900`, `MAX_QUEUE_SIZE=2000` - `AUTHN_HEADER=X-Auth-Token`, `AUTHN_TOKEN=` (optional shared auth secret) - `UPSTREAM_JUDGE0_URL=` (optional stock Judge0 URL for proxying Go/Rust/PHP/TS/Kotlin/etc.)