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
16 changes: 16 additions & 0 deletions frameworks/Funxy/funxy-stdlib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Funxy (stdlib)

[Funxy](https://github.com/funvibe/funxy) is a general-purpose scripting language with static typing and type inference.

- Homepage: https://github.com/funvibe/funxy
- Documentation: https://github.com/funvibe/funxy/tree/main/docs

This implementation targets the following TechEmpower tests:

- Plaintext (`/plaintext`)
- JSON Serialization (`/json`)

Implementation files in this directory:

- `supervisor.lang`
- `worker.lang`
22 changes: 22 additions & 0 deletions frameworks/Funxy/funxy-stdlib/benchmark_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"framework": "funxy",
"maintainers": ["oakulikov", "funvibe"],
"tests": [
{
"default": {
"json_url": "/json",
"plaintext_url": "/plaintext",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
"framework": "funxy",
"language": "Funxy",
"webserver": "None",
"os": "Linux",
"display_name": "funxy_stdlib",
"notes": "",
"versus": "None"
}
}
]
}
23 changes: 23 additions & 0 deletions frameworks/Funxy/funxy-stdlib/funxy.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM ubuntu:22.04

RUN apt-get update && \
apt-get install -y curl ca-certificates && \
rm -rf /var/lib/apt/lists/*

# Install Funxy binary directly (non-interactive, Docker-friendly)
RUN set -eux; \
arch="$(dpkg --print-architecture)"; \
case "$arch" in \
amd64) funxy_arch="amd64" ;; \
arm64) funxy_arch="arm64" ;; \
*) echo "Unsupported architecture: $arch" >&2; exit 1 ;; \
esac; \
curl -fsSL -o /usr/local/bin/funxy "https://github.com/funvibe/funxy/releases/latest/download/funxy-linux-${funxy_arch}"; \
chmod +x /usr/local/bin/funxy

WORKDIR /app
COPY supervisor.lang worker.lang ./

EXPOSE 8080

CMD ["funxy", "vmm", "supervisor.lang"]
32 changes: 32 additions & 0 deletions frameworks/Funxy/funxy-stdlib/supervisor.lang
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import "lib/vmm" (spawnVMGroup)
import "lib/time" (sleepMs)
import "lib/sys" (sysScriptDir, sysCPUCount)
import "lib/path" (pathJoin)
import "lib/flag" (flagSet, flagParse, flagGet)

// Override with --workers N.
// If omitted or <= 0, use runtime CPU parallelism from sysCPUCount().
flagSet("workers", 0, "number of worker VMs (<=0 means auto-detect)")
flagParse()
workersFlag = flagGet("workers")
logicalCPU = sysCPUCount()
cores = if workersFlag > 0 { workersFlag } else { logicalCPU }
if cores <= 0 {
panic("invalid worker count: " ++ show(cores))
}

worker_path = pathJoin([sysScriptDir(), "worker.lang"])
print("Starting TFB cluster with workers=" ++ show(cores) ++ " (runtime_cpu=" ++ show(logicalCPU) ++ ")")

match spawnVMGroup(worker_path, {
group: "tfb_web",
capabilities: ["lib/http", "lib/json"]
}, cores) {
Ok(ids) -> print("Started Funxy TFB cluster. Workers: " ++ show(ids))
Fail(e) -> panic("Failed to start cluster: " ++ e)
}

// Block the supervisor from exiting so the VMM stays alive
while true {
sleepMs(1000)
}
25 changes: 25 additions & 0 deletions frameworks/Funxy/funxy-stdlib/worker.lang
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import "lib/http" (httpServe)
import "lib/json" (jsonEncode)

// Pre-allocate response structures to avoid allocation overhead during the hot path
headers_plain = [("Server", "Funxy"), ("Content-Type", "text/plain")]
msg_plain = "Hello, World!"

// TechEmpower requires the Date header, but lib/http automatically adds and caches
// an accurate Date header for us, so we don't need to generate it manually.
httpServe(8080, fun(req) {
match req.path {
"/plaintext" -> {
status: 200,
headers: headers_plain,
body: msg_plain
}
"/json" -> {
status: 200,
headers: [("Server", "Funxy"), ("Content-Type", "application/json")],
// Construct the map dynamically for each request as per TFB rules
body: jsonEncode({ message: "Hello, World!" })
}
_ -> { status: 404, body: "" }
}
})