Spaces:
Running
Running
Commit History
-
Update similarity.py Running
Verified signatureb00036c
-
main - Approximate real RAM usage and shrink the oversized alerts panel
RAM reading subtracted nothing from cgroup v2's memory.current, which includes reclaimable file cache (image/video downloads, mmap'd model weights) — inflating the number shown vs what's actually pinned. Subtract inactive_file from memory.stat, matching the "working set" calculation Docker/Kubernetes use. Also stopped the alerts panel from flex-growing to fill the whole remaining page height; it now caps at 200px like a normal compact panel.f20adc7 -
main - Remove RSS-spike and cache-thrashing alerts, both were noise
Real traffic (~80 req/min, cache always at its 500-entry cap) made both fire constantly on healthy workers: eviction under a full cache is the normal steady state for this workload, not thrashing, and the resulting image churn keeps RSS climbing in ways indistinguishable from the initial cache warm-up the RSS-spike gate was meant to exclude. Dropped both alerts and the instrumentation that only existed to support them. Only worker-down and error-rate-spike alerts remain — both genuine regardless of traffic volume.4e28d86
-
main - Change Space emoji from globe to muscle
e5c1c23 -
main - Sort worker cards by name instead of pid
Sorting by pid put the lettered names in an arbitrary, jumbled order on screen (e.g. G, D, F, C...). Sort by name so cards read left-to-right as A, B, C... regardless of the underlying pid order.7ea4392 -
main - Give workers stable names instead of raw pids
Pids change on every restart, making it hard to tell workers apart across deploys or to notice a specific one crash-looping. Each worker now claims a name ("Worker A", "Worker B", ...) from a small shared file the first time it starts, keeps it for its whole lifetime, and never reuses a name for a different pid — so a restart shows up as a new name appearing while the old one's alert fades out. Alerts and worker cards use the name; the pid is still available as a tooltip on the card.46ea438 -
main - Replace log panel with 5-min health stats and anomaly alerts
Raw log tailing on the monitoring page duplicated HF's own log viewer and wrote every log line to disk per worker for no real benefit. Removed that entirely (_FileLogHandler, _trim_log_files, get_log_lines, /logs) and replaced it with per-worker in-process instrumentation: a rolling 5-minute window of per-image latency/success and cache evictions, aggregated into throughput/error-rate/latency health stats and four anomaly alerts (worker not reporting, RSS spike past the cache warm-up grace period, cache thrashing, error-rate spike). All aggregation stays local per worker and piggybacks on the existing 5s stats-reporter tick, so it adds negligible overhead. Also dropped the dead `Model` import and unused `os` import in main.py.3200602 -
main - Add design doc for replacing log panel with health stats and alerts
8b92e8e -
main - Match HF's log viewer typography: system monospace, near-white text
Own log panel felt visually noisier than HF's native container log view. Switch to a system monospace stack, more line-height, and a single bright near-white for normal lines instead of a dimmer secondary-ink tone, keeping color reserved for warning/error only.0018b11 -
main - Enlarge the log panel, deepen its buffer, and fix log text colors
Log box was a fixed 220px showing only the last 100 merged lines refreshed every 5s, so busy bursts wiped it before anyone could read it and it felt sluggish next to HF's own log viewer. Let it flex to fill the page, request 400 lines on a 2s poll, and raise the per-worker file cap to 1000 lines so there's enough headroom. Also replaced the ad-hoc log text colors with the validated dark-mode status palette (critical/warning) plus a proper secondary-ink token for normal lines instead of a stray blue-gray.dfdf3ba -
main - Replace SSE proxy with simple log polling, rewrite JS as ES5 for HF iframe compat
4139463 -
main - Fix SSE reconnect loop: catch errors, set retry 60s, return HTTP status on failure
e2aaf7c -
main - Defensive stats render and handle HF SSE event types for log stream
9f11300 -
main - Embed real-time HF container logs via SSE proxy on monitoring page
6366908 -
main - Increase image cache to 500 and malloc trim interval to 15 minutes
87397d6 -
main - Fix req counter layout: separate RSS and unit/req onto distinct lines
be6946a -
main - Increase request counter font size and brightness
60b28cb -
main - Set Space short_description to visual similarity API tagline
fbca4a7 -
main - Override Space short_description to remove health monitor subtitle
bec9805 -
main - Brighten request counter text colour for legibility
191d371 -
main - Rename HF Space title to Prozis Similarity Service
c1a5139 -
main - Move RAM/CPU into header meta line, remove dedicated machine bar
15bea90 -
main - Fix RSS bar visibility: explicit colour and increase track height
41a7107 -
main - Add request counter per worker and replace cache bar with RSS bar
Track _request_count per worker in check_similarity(); expose via get_memory_stats(). Cards now show RSS bar (relative to heaviest worker = 100%) coloured with the same green/amber/red as the RSS value, plus request count. Cache count stays as text in the card top-right.d39ee38 -
main - Reduce machine stats bar height
20bbae3 -
main - Fix machine RAM and CPU readings to match HF container metrics
RAM: switch from binary (/ 1024^3) to decimal (/ 1e9) division so the total matches HF's display (32 GB instead of 29 GB). CPU: replace psutil.cpu_percent() (reads host-wide /proc/stat) with delta tracking on /sys/fs/cgroup/cpu.stat usage_usec (cgroup v2) with cgroup v1 and psutil fallbacks. Updated every 5s by the background reporter so the reading reflects container-scoped CPU like HF shows.a07873f -
main - Read container RAM from cgroup instead of host psutil
psutil.virtual_memory() returns the host machine total (493 GB on the HF server), not the container limit. Read /sys/fs/cgroup/memory.max and memory.current (cgroup v2) with a cgroup v1 fallback so the RAM bar matches the HF Space tier allocation (32 GB).f7f2f77 -
main - Add machine RAM and CPU stats bar to monitoring page
Add get_machine_stats() using psutil.virtual_memory() and cpu_percent(). Show as a compact two-bar row (RAM and CPU with colour-coded progress) between the header and the worker cards. Warm up cpu_percent() at module load to avoid the first-call zero reading.416ab0a -
main - Revert to card grid, remove logs section, fix colours
Remove log section and row layout. Cards back with top colour border, bright RSS colours (#4ade80 / #fbbf24 / #f87171), compact sizing (~85px tall) to fit above HF logs panel. Header on one line to save vertical space. JS polls /stats every 5s.0eb29b9 -
main - Fix log capture across all workers and improve text contrast
Replace in-memory per-process log buffer with file-based handler writing to /tmp/similarity_logs/{pid}.log; get_log_lines() aggregates across all worker files so logs from every process are visible. Add _trim_log_files() to the periodic trimmer. Brighten log text colours (msg #cbd5e1, ts #64748b, info #60a5fa) and worker label colours (#94a3b8).29f1059 -
main - Set container timezone to Europe/Lisbon for correct log timestamps
87e8b1d -
main - Compact worker rows, add live log section to monitoring page
Replace card grid with compact single-line rows (border-left colour coded, inline cache progress and RSS). Add in-memory log buffer (_MemHandler) and /stats JSON endpoint; page polls every 5s and renders logs directly below the workers panel. Fixes illegible PID colour and oversized cards that clashed with HF Logs panel.2d70896 -
main - Reduce workers to 8, increase cache to 300, redesign monitoring page
Remove /health endpoint and per-request MEM log; monitoring is now internal only via background reporter. Root page redesigned with card grid, colour-coded RSS (green/amber/red), cache progress bars and server-side rendering with meta-refresh.5bd83d8
-
main - Mitigate glibc malloc fragmentation from cumulative image throughput
RSS kept climbing per worker even after the image cache saturated at its 200-entry cap, well past what the cached array sizes justify -- classic glibc arena/mmap-threshold fragmentation from repeated decode/resize allocations on varied image sizes. Cap arena count via MALLOC_ARENA_MAX and periodically call malloc_trim(0) to hand freed memory back to the OS, without touching what images are accepted or how they're processed.1ad39c4 -
main - Report worker memory stats on a background timer, not only per-request
/health only showed workers that had already handled a request, so under light or unevenly balanced traffic some of the 10 workers never appeared. Each worker now writes its own stats every 5s from startup regardless of whether it receives any traffic.0a451cf -
main - Show all workers' memory stats together on the health endpoint
/health previously only reflected whichever worker handled that request, requiring several refreshes to see the full picture. Each worker now persists its stats to a shared file so /health and the root page can show all 10 workers at once.494f72d -
main - Fix race condition corrupting MobileNet weights on cold start
10 uvicorn workers all lazy-loading the same shared weights file at once caused HDF5 corruption ("free block size is zero"), silently returning a similarityMobileNet of 0 for affected requests. Bake the weights into the image at build time so no worker downloads at runtime, and add a lock around the lazy singleton to also guard against intra-process races.d13163e -
main - Add RSS memory logging and live worker stats on health/root endpoints
Needed to diagnose remaining unbounded memory growth after dd5dd8f: logs RSS per request in check_similarity and exposes it via /health, surfaced live on the root page for quick inspection.28d9db8 -
main - Fix TensorFlow eager call memory leak in mobilenet_sim
dd5dd8f
-
reduce-cache-size - Reduce image cache max size from 500 to 200 to lower memory usage
b57b3cd
-
resize-cache - Resize images before caching to limit memory usage (max 512px)
cadaa92 -
add-gitignore - Add .gitignore
fdee147 -
Update similarity.py
Verified signaturea1c40c4 -
Update similarity.py
Verified signaturea716324 -
Update similarity.py
Verified signatureaced9ba -
Update requirements.txt
Verified signature356ac7a -
Update similarity.py
Verified signature7f64c97 -
Update similarity.py
Verified signature6c3bb59 -
Update similarity.py
Verified signature2a9742d -
Update similarity.py
Verified signaturea0f65eb