fix(server): honor HYPERGLASS_WORKERS for web worker count - #381
Open
WilhelmZA wants to merge 1 commit into
Open
fix(server): honor HYPERGLASS_WORKERS for web worker count#381WilhelmZA wants to merge 1 commit into
WilhelmZA wants to merge 1 commit into
Conversation
The web-worker count was hardcoded to 2x CPU cores when debug was off (via an unused `workers` property and duplicate inline logic in run()), so a 24-core host span 48 uvicorn workers and the documented HYPERGLASS_WORKERS env var was silently ignored. Add a real `workers` settings field (HYPERGLASS_WORKERS) and a `worker_count` property that honors it (clamped to >= 1), falling back to 1 in debug mode or 2x CPU cores otherwise. run() now uses Settings.worker_count.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
HyperglassSettings.workersis a computed property hardcoded tocpu_count(2)(2x logical cores) whenever
debugis off, andhyperglass/main.pyduplicatesthat same inference inline. There is no settings field backing it, so the
HYPERGLASS_WORKERSenvironment variable is silently ignored.On a 24-core host this starts 48 uvicorn workers regardless of intent — each
a full process holding the app plus its own Redis connections — with no
supported way to cap it. For a looking glass that is far more than needed.
Fix
workerssettings field (HYPERGLASS_WORKERS),Optional[int],default
None.workersproperty withworker_count, which honors thefield (clamped to
>= 1) and otherwise keeps the previous behavior:1indebug mode, else
2xCPU cores.run()now usesSettings.worker_countinstead of duplicating the inference.HYPERGLASS_WORKERSdebug40Notes
models/system.pyandmain.py, independent ofany other in-flight work, and applies cleanly to the current
main.HYPERGLASS_WORKERSisunset.
worker_count.