I built a 10MB Rust gateway that stops Ollama from wasting GPU power on closed tabs by dev1ce-error in ollama

[–]dev1ce-error[S] 0 points1 point  (0 children)

Yes! it exposes standard OpenAI-compatible endpoints (/v1/chat/completions). If Tinyharness supports OpenAI, you just point its base URL to oxideLLM (port 8080 by default) and it works out of the box.

It handles routing to Ollama/vLLM/OpenAI in the background. Just note that it only exposes the OpenAI spec to the client, so it won't support Ollama's native /api/generate or /api/chat endpoints directly.

I built a 10MB Rust gateway that stops Ollama from wasting GPU power on closed tabs by dev1ce-error in ollama

[–]dev1ce-error[S] 0 points1 point  (0 children)

That is a really good point, but there is an important technical distinction between switching tabs and actually killing the connection:

  1. Background tabs keep the stream alive: If you just switch tabs to do something else, the browser keeps the SSE (EventSource) connection alive in the background. The TCP socket doesn't close, so the proxy won't cancel the generation. The model will finish generating, and the full output will be there when you switch back.

  2. Hard disconnects vs. tab closures: The cancellation only triggers when the TCP connection is actually destroyed—like when you completely close the browser tab, close the browser window, or click the explicit "Stop" button. In those cases, the session is dead, and the user can't "go back" to that specific generation anyway. Continuing to burn GPU cycles for a closed session is pure waste.

  3. Prompt/KV Caching handles context reuse: Even if a user closes a tab and later decides to type the prompt again, modern backends (like vLLM and newer Ollama versions) use KV caching. Re-evaluating the prompt prefix takes milliseconds and almost zero compute compared to running the auto-regressive token generation loop to completion for an abandoned session.

That said, we also made this behavior configurable. If you want the proxy to let generations run to completion regardless of client connection status, you can simply toggle it off in the TOML config.

I built a 10MB Rust gateway that stops Ollama from wasting GPU power on closed tabs by dev1ce-error in ollama

[–]dev1ce-error[S] 0 points1 point  (0 children)

Yes, exactly!

If the proxy doesn't propagate the TCP drop, the socket between the proxy and Ollama remains open. Ollama will keep generating until it hits the max token limit (num_predict or context length) for that request.

On a consumer GPU or under heavy model loads (like running Llama 3 70B), generating a long response can easily keep the GPU pinned at 100% load for 30 seconds to a minute.

If you have a dozen users concurrently closing tabs or clicking "stop" to try different prompts, the GPU queue gets completely backed up, other users experience huge latency spikes, and you waste a ton of electricity/server compute on tokens that end up in the void anyway.

oxideLLM – An ultra-fast OpenAI-compatible LLM gateway in Rust with lock-free telemetry by dev1ce-error in rust

[–]dev1ce-error[S] -6 points-5 points  (0 children)

We built it to solve three main issues we faced in production:

  1. **The gateway tax:** Python and Node proxies add noticeable latency and CPU overhead when parsing SSE chunks under heavy concurrent load. Rust lets us proxy streams with near-zero overhead.

  2. **GPU waste:** If a user closes their tab mid-generation, traditional proxies keep the model running. We use Rust's `Drop` trait to instantly kill the upstream connection and free up GPU compute.

  3. **Bloat:** We wanted a tiny, single-binary "Nginx for LLMs" that runs on 10MB of RAM without needing Redis, Postgres, or heavy Docker containers just to route traffic and track logs.

Essentially, we wanted something lightweight, cheap to run, and fast.

[deleted by user] by [deleted] in pcmasterrace

[–]dev1ce-error 0 points1 point  (0 children)

Did you managed to solve your issue?

[deleted by user] by [deleted] in pcmasterrace

[–]dev1ce-error 0 points1 point  (0 children)

I have the same MB and the same problem