Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- api/request_class.py +65 -0
- web/public/AIOS_DEPLOY_RECEIPT +1 -1
RELEASES.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": [
|
| 4 |
{
|
| 5 |
"version": "v83",
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "c26b3f49b93e",
|
| 3 |
"releases": [
|
| 4 |
{
|
| 5 |
"version": "v83",
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
c26b3f49b93e
|
api/request_class.py
CHANGED
|
@@ -120,6 +120,64 @@ class _Counters:
|
|
| 120 |
_COUNTERS = _Counters()
|
| 121 |
|
| 122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
def status():
|
| 124 |
"""Snapshot of heavy request admission for a settings or health surface."""
|
| 125 |
c = _COUNTERS
|
|
@@ -233,10 +291,17 @@ class HeavyGate:
|
|
| 233 |
|
| 234 |
c.add("in_flight", 1)
|
| 235 |
c.add("admitted", 1)
|
|
|
|
|
|
|
|
|
|
| 236 |
try:
|
| 237 |
await self.app(scope, _replay(body_msgs, receive), send_wrapped)
|
| 238 |
finally:
|
| 239 |
release()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
|
| 241 |
|
| 242 |
async def _read_body(receive, limit):
|
|
|
|
| 120 |
_COUNTERS = _Counters()
|
| 121 |
|
| 122 |
|
| 123 |
+
class _StackSampler:
|
| 124 |
+
"""Opt-in (AIOS_HEAVY_PROFILE=1): samples app frames while heavy requests run, logs the hot ones."""
|
| 125 |
+
|
| 126 |
+
INTERVAL = 0.2
|
| 127 |
+
|
| 128 |
+
def __init__(self):
|
| 129 |
+
self.lock = threading.Lock()
|
| 130 |
+
self.active = 0
|
| 131 |
+
self.counts = {}
|
| 132 |
+
self.thread = None
|
| 133 |
+
|
| 134 |
+
def begin(self):
|
| 135 |
+
with self.lock:
|
| 136 |
+
self.active += 1
|
| 137 |
+
if self.active == 1:
|
| 138 |
+
self.counts = {}
|
| 139 |
+
if self.thread is None or not self.thread.is_alive():
|
| 140 |
+
self.thread = threading.Thread(target=self._run, name="heavy-profile", daemon=True)
|
| 141 |
+
self.thread.start()
|
| 142 |
+
|
| 143 |
+
def end(self, label, seconds):
|
| 144 |
+
with self.lock:
|
| 145 |
+
self.active -= 1
|
| 146 |
+
counts = dict(self.counts)
|
| 147 |
+
if seconds < 3 or not counts:
|
| 148 |
+
return
|
| 149 |
+
top = sorted(counts.items(), key=lambda kv: -kv[1])[:18]
|
| 150 |
+
print(f"[heavy-profile] {label} {seconds:.1f}s " + " | ".join(
|
| 151 |
+
f"{name} {n * self.INTERVAL:.1f}s" for name, n in top), flush=True)
|
| 152 |
+
|
| 153 |
+
def _run(self):
|
| 154 |
+
import sys
|
| 155 |
+
import time
|
| 156 |
+
me = threading.get_ident()
|
| 157 |
+
while True:
|
| 158 |
+
time.sleep(self.INTERVAL)
|
| 159 |
+
with self.lock:
|
| 160 |
+
if self.active <= 0:
|
| 161 |
+
self.thread = None
|
| 162 |
+
return
|
| 163 |
+
for tid, frame in sys._current_frames().items():
|
| 164 |
+
if tid == me:
|
| 165 |
+
continue
|
| 166 |
+
seen = set()
|
| 167 |
+
while frame is not None:
|
| 168 |
+
code = frame.f_code
|
| 169 |
+
path = code.co_filename.replace("\\", "/")
|
| 170 |
+
if ("/api/" in path or "/platform/" in path) and "site-packages" not in path:
|
| 171 |
+
name = f"{code.co_name}@{path.rsplit('/', 1)[-1]}"
|
| 172 |
+
if name not in seen:
|
| 173 |
+
seen.add(name)
|
| 174 |
+
self.counts[name] = self.counts.get(name, 0) + 1
|
| 175 |
+
frame = frame.f_back
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
_SAMPLER = _StackSampler() if os.environ.get("AIOS_HEAVY_PROFILE") == "1" else None
|
| 179 |
+
|
| 180 |
+
|
| 181 |
def status():
|
| 182 |
"""Snapshot of heavy request admission for a settings or health surface."""
|
| 183 |
c = _COUNTERS
|
|
|
|
| 291 |
|
| 292 |
c.add("in_flight", 1)
|
| 293 |
c.add("admitted", 1)
|
| 294 |
+
started = asyncio.get_running_loop().time()
|
| 295 |
+
if _SAMPLER is not None:
|
| 296 |
+
_SAMPLER.begin()
|
| 297 |
try:
|
| 298 |
await self.app(scope, _replay(body_msgs, receive), send_wrapped)
|
| 299 |
finally:
|
| 300 |
release()
|
| 301 |
+
if _SAMPLER is not None:
|
| 302 |
+
q = scope.get("query_string", b"").decode("latin-1")[:60]
|
| 303 |
+
_SAMPLER.end(f"{scope.get('method')} {scope.get('path')}?{q}",
|
| 304 |
+
asyncio.get_running_loop().time() - started)
|
| 305 |
|
| 306 |
|
| 307 |
async def _read_body(receive, limit):
|
web/public/AIOS_DEPLOY_RECEIPT
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
8339de2c226c7fa49f53425ed8f57b65aabda21c8ae1c2d4529196749840af5b
|