Skip to content

Commit c288f55

Browse files
authored
Merge branch 'main' into add-libreactorng
2 parents 7e68b64 + 979ea8e commit c288f55

28 files changed

Lines changed: 366 additions & 0 deletions

File tree

frameworks/slimeweb/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM python:3.13-slim
2+
3+
WORKDIR /app
4+
5+
RUN pip install --no-cache-dir uv slimeweb
6+
7+
RUN slime new arena
8+
9+
WORKDIR /app/arena
10+
11+
RUN slime add asyncpg
12+
13+
COPY main.py /app/arena/main.py
14+
15+
EXPOSE 8080
16+
17+
CMD ["slime","run","main.py"]

frameworks/slimeweb/main.py

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
import json
2+
import os
3+
4+
import asyncpg as pg
5+
from slimeweb import Slime, SlimeCompression
6+
7+
app = Slime(__file__)
8+
9+
10+
def load_json_processing_file():
11+
with open("/data/dataset.json", "r") as file:
12+
return json.load(file)
13+
14+
15+
JSON_DATASET = load_json_processing_file()
16+
QUERY_STMT = """
17+
SELECT id, name, category, price, quantity, active, tags, rating_score, rating_count
18+
FROM items
19+
WHERE price BETWEEN $1 AND $2
20+
LIMIT $3
21+
"""
22+
DB_POOL = None
23+
24+
25+
@app.route("/baseline11", method=["GET", "POST"])
26+
def baseline_test(req, resp):
27+
if req.method == "GET":
28+
result = 0
29+
for q_val in req.query.values():
30+
try:
31+
result += int(q_val)
32+
except ValueError:
33+
pass
34+
return resp.plain(str(result))
35+
else:
36+
result = 0
37+
for q_val in req.query.values():
38+
try:
39+
result += int(q_val)
40+
except ValueError:
41+
pass
42+
try:
43+
result += int(req.text)
44+
except ValueError:
45+
pass
46+
return resp.plain(str(result))
47+
48+
49+
@app.route("/pipeline", method="GET")
50+
def pipeline_test(req, resp):
51+
return resp.plain("ok")
52+
53+
54+
# body_size by default it will read 10MB
55+
# setting read_size as 25MB
56+
@app.route("/upload", method="POST", body_size=1024 * 1024 * 25)
57+
def upload_test(req, resp):
58+
result = len(req.body)
59+
return resp.plain(str(result))
60+
61+
62+
@app.route(
63+
"/json/{count}", method="GET", compression=SlimeCompression.All, comp_level=1
64+
)
65+
def json_test(req, resp):
66+
global JSON_DATASET
67+
count = int(req.params["count"])
68+
multiplier = int(req.query["m"])
69+
result = []
70+
for data in JSON_DATASET[:count]:
71+
result.append(
72+
{
73+
"id": data["id"],
74+
"name": data["name"],
75+
"category": data["category"],
76+
"price": data["price"],
77+
"quantity": data["quantity"],
78+
"active": data["active"],
79+
"tags": data["tags"],
80+
"rating": {
81+
"score": data["rating"]["score"],
82+
"count": data["rating"]["count"],
83+
},
84+
"total": data["price"] * data["quantity"] * multiplier,
85+
}
86+
)
87+
return resp.json({"items": result, "count": count})
88+
89+
90+
# Websocket in slime are event driven
91+
# echo back based on the message type
92+
@app.websocket("/ws")
93+
def websocket_test(req, resp):
94+
def echo_me(msg):
95+
if isinstance(msg, str):
96+
return resp.send_text(msg)
97+
else:
98+
return resp.send_bytes(msg)
99+
100+
resp.on_message(echo_me)
101+
102+
103+
@app.route("/async-db", method="GET")
104+
async def async_db_test(req, resp):
105+
global QUERY_STMT, DB_POOL
106+
if DB_POOL is None:
107+
return resp.json({"items": [], "count": 0})
108+
min = int(req.query["min"])
109+
max = int(req.query["max"])
110+
limit = int(req.query["limit"])
111+
result = []
112+
data_result = None
113+
async with DB_POOL.acquire() as conn:
114+
data_result = await conn.fetch(QUERY_STMT, min, max, limit)
115+
for data in data_result:
116+
result.append(
117+
{
118+
"id": data["id"],
119+
"name": data["name"],
120+
"category": data["category"],
121+
"price": data["price"],
122+
"quantity": data["quantity"],
123+
"active": data["active"],
124+
"tags": json.loads(data["tags"]),
125+
"rating": {
126+
"score": data["rating_score"],
127+
"count": data["rating_count"],
128+
},
129+
}
130+
)
131+
return resp.json({"items": result, "count": len(result)})
132+
133+
134+
@app.start()
135+
async def init():
136+
global DB_POOL
137+
try:
138+
DB_POOL = await pg.create_pool(
139+
dsn=os.environ["DATABASE_URL"],
140+
min_size=5,
141+
max_size=int(os.environ.get("DATABASE_MAX_CONN", 256)),
142+
)
143+
print("Pool is created successfully")
144+
except Exception as e:
145+
print("Failed to create pool", e)
146+
DB_POOL = None
147+
148+
149+
if __name__ == "__main__":
150+
app.serve(host="0.0.0.0", port=8080, static_path="/data/static")

frameworks/slimeweb/meta.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"display_name": "SlimeWeb",
3+
"language": "Python",
4+
"type": "tuned",
5+
"engine": "hyper",
6+
"description": "SlimeWeb is a fast lightweight framework for python powered by rust",
7+
"repo": "https://github.com/ATOMMAX-2001/Slime/",
8+
"enabled": true,
9+
"tests": [
10+
"baseline",
11+
"pipelined",
12+
"limited-conn",
13+
"json",
14+
"json-comp",
15+
"upload",
16+
"echo-ws",
17+
"api-4",
18+
"api-16",
19+
"static",
20+
"async-db"
21+
],
22+
"maintainers": ["ATOMMAX-2001"]
23+
}

site/data/baseline-4096.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,25 @@
825825
"status_4xx": 0,
826826
"status_5xx": 0
827827
},
828+
{
829+
"framework": "SlimeWeb",
830+
"language": "Python",
831+
"rps": 71705,
832+
"avg_latency": "21.90ms",
833+
"p99_latency": "78.00ms",
834+
"cpu": "1322.5%",
835+
"memory": "150MiB",
836+
"connections": 4096,
837+
"threads": 64,
838+
"duration": "5s",
839+
"pipeline": 1,
840+
"bandwidth": "8.41MB/s",
841+
"reconnects": 0,
842+
"status_2xx": 358528,
843+
"status_3xx": 0,
844+
"status_4xx": 0,
845+
"status_5xx": 0
846+
},
828847
{
829848
"framework": "spring-boot",
830849
"language": "Java",

site/data/baseline-512.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,25 @@
825825
"status_4xx": 0,
826826
"status_5xx": 0
827827
},
828+
{
829+
"framework": "SlimeWeb",
830+
"language": "Python",
831+
"rps": 69917,
832+
"avg_latency": "6.54ms",
833+
"p99_latency": "17.70ms",
834+
"cpu": "1257.0%",
835+
"memory": "184MiB",
836+
"connections": 512,
837+
"threads": 64,
838+
"duration": "5s",
839+
"pipeline": 1,
840+
"bandwidth": "8.20MB/s",
841+
"reconnects": 0,
842+
"status_2xx": 349588,
843+
"status_3xx": 0,
844+
"status_4xx": 0,
845+
"status_5xx": 0
846+
},
828847
{
829848
"framework": "spring-boot",
830849
"language": "Java",

site/data/frameworks.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,13 @@
404404
"type": "tuned",
405405
"engine": "sisk"
406406
},
407+
"SlimeWeb": {
408+
"dir": "slimeweb",
409+
"description": "SlimeWeb is a fast lightweight framework for python powered by rust",
410+
"repo": "https://github.com/ATOMMAX-2001/Slime/",
411+
"type": "tuned",
412+
"engine": "hyper"
413+
},
407414
"spring-boot": {
408415
"dir": "spring-boot",
409416
"description": "Spring Boot with embedded Tomcat on JDK 25 with virtual threads.",

site/data/limited-conn-4096.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,25 @@
825825
"status_4xx": 0,
826826
"status_5xx": 0
827827
},
828+
{
829+
"framework": "SlimeWeb",
830+
"language": "Python",
831+
"rps": 69467,
832+
"avg_latency": "36.89ms",
833+
"p99_latency": "132.20ms",
834+
"cpu": "1319.7%",
835+
"memory": "151MiB",
836+
"connections": 4096,
837+
"threads": 64,
838+
"duration": "5s",
839+
"pipeline": 1,
840+
"bandwidth": "8.15MB/s",
841+
"reconnects": 33548,
842+
"status_2xx": 347337,
843+
"status_3xx": 0,
844+
"status_4xx": 0,
845+
"status_5xx": 0
846+
},
828847
{
829848
"framework": "spring-boot",
830849
"language": "Java",

site/data/limited-conn-512.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,25 @@
825825
"status_4xx": 0,
826826
"status_5xx": 0
827827
},
828+
{
829+
"framework": "SlimeWeb",
830+
"language": "Python",
831+
"rps": 72654,
832+
"avg_latency": "6.12ms",
833+
"p99_latency": "16.70ms",
834+
"cpu": "1311.5%",
835+
"memory": "131MiB",
836+
"connections": 512,
837+
"threads": 64,
838+
"duration": "5s",
839+
"pipeline": 1,
840+
"bandwidth": "8.52MB/s",
841+
"reconnects": 36257,
842+
"status_2xx": 363270,
843+
"status_3xx": 0,
844+
"status_4xx": 0,
845+
"status_5xx": 0
846+
},
828847
{
829848
"framework": "spring-boot",
830849
"language": "Java",

site/data/pipelined-4096.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,25 @@
779779
"status_4xx": 0,
780780
"status_5xx": 0
781781
},
782+
{
783+
"framework": "SlimeWeb",
784+
"language": "Python",
785+
"rps": 72670,
786+
"avg_latency": "301.02ms",
787+
"p99_latency": "2.06s",
788+
"cpu": "1263.9%",
789+
"memory": "178MiB",
790+
"connections": 4096,
791+
"threads": 64,
792+
"duration": "5s",
793+
"pipeline": 16,
794+
"bandwidth": "8.59MB/s",
795+
"reconnects": 0,
796+
"status_2xx": 363350,
797+
"status_3xx": 0,
798+
"status_4xx": 0,
799+
"status_5xx": 0
800+
},
782801
{
783802
"framework": "spring-boot",
784803
"language": "Java",

site/data/pipelined-512.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,25 @@
779779
"status_4xx": 0,
780780
"status_5xx": 0
781781
},
782+
{
783+
"framework": "SlimeWeb",
784+
"language": "Python",
785+
"rps": 70690,
786+
"avg_latency": "107.34ms",
787+
"p99_latency": "147.50ms",
788+
"cpu": "1238.3%",
789+
"memory": "135MiB",
790+
"connections": 512,
791+
"threads": 64,
792+
"duration": "5s",
793+
"pipeline": 16,
794+
"bandwidth": "8.36MB/s",
795+
"reconnects": 0,
796+
"status_2xx": 353453,
797+
"status_3xx": 0,
798+
"status_4xx": 0,
799+
"status_5xx": 0
800+
},
782801
{
783802
"framework": "spring-boot",
784803
"language": "Java",

0 commit comments

Comments
 (0)