open-webui/backend/open_webui/utils
Classic298 ec0e60033b
perf: use the orjson codec for the permission deep copy (#27807)
`get_permissions` deep-copies the default permission tree with a `json.loads(json.dumps(...))` round trip before merging group permissions into it. It runs on signin, signup, the permissions endpoint, OAuth, and the chat-completion middleware.

It now goes through `JSONCodec`, which selects orjson when `ENABLE_ORJSON` is set. The intermediate string never leaves the expression, so neither the escaping nor the separator differences between the two backends are observable; only the resulting object is used.

`default_permissions` always originates from `Config.get('user.permissions')`, a SQLAlchemy `JSON` column, so the tree is JSON-native by construction and the round trip is exact.

Note for anyone tempted to simplify this to `copy.deepcopy`: measured on the real `DEFAULT_USER_PERMISSIONS` shape over 200k iterations, `deepcopy` takes 3.51s against 1.45s for the stdlib round trip and 0.40s for orjson. The round trip is the fast option, not a workaround.

With `ENABLE_ORJSON` unset, which is the default, `JSONCodec` is stdlib `json` and this call site behaves exactly as before.
2026-07-31 17:32:14 -04:00
..
access_control perf: use the orjson codec for the permission deep copy (#27807) 2026-07-31 17:32:14 -04:00
images refac 2026-07-01 02:48:29 -05:00
mcp refac 2026-06-29 11:56:00 -05:00
telemetry refac(telemetry): drop deprecated semconv SpanAttributes subclass (#25784) 2026-06-29 02:05:34 -05:00
actions.py fix: enforce action availability and model access on the chat action route (#27243) 2026-07-23 12:23:05 -04:00
anthropic.py refac 2026-07-27 03:01:19 -04:00
asgi_middleware.py fix: report sub-second timings in the X-Process-Time header (#27368) 2026-07-23 18:09:23 -05:00
audit.py refac 2026-07-23 22:52:23 -04:00
auth.py refac 2026-07-27 19:24:03 -04:00
automations.py refac 2026-07-27 03:54:05 -04:00
calendar.py refac 2026-07-31 17:30:47 -04:00
channels.py refac 2026-03-17 17:58:01 -05:00
chat.py perf: read the model pool with one HGETALL instead of one HGET per model (#27821) 2026-07-31 17:25:53 -04:00
chat_fork.py refac 2026-07-23 02:54:56 -04:00
chat_id.py refac 2026-07-26 21:12:14 -04:00
chat_variables.py refac 2026-07-24 01:44:30 -04:00
code_interpreter.py perf: use the orjson codec to parse Jupyter kernel messages (#27812) 2026-07-31 17:32:05 -04:00
context_compaction.py refac 2026-07-27 03:05:26 -04:00
embeddings.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
files.py refac 2026-07-23 21:29:33 -04:00
filter.py refac 2026-07-27 02:36:15 -04:00
groups.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
headers.py chore: format 2026-07-27 00:12:47 -04:00
json_codec.py fix: escape line separators in orjson output (#27819) 2026-07-31 17:25:30 -04:00
json_response.py perf: optional orjson JSON codec behind ENABLE_ORJSON (#27583) 2026-07-27 03:45:37 -04:00
logger.py refac 2026-07-27 02:24:41 -04:00
memory.py refac 2026-07-27 19:39:36 -04:00
middleware.py perf: read the model pool with one HGETALL instead of one HGET per model (#27821) 2026-07-31 17:25:53 -04:00
misc.py refac 2026-07-27 02:49:08 -04:00
model_ids.py refac 2026-07-26 23:09:22 -04:00
models.py perf: stop refetching the model row and user groups in the completion access check (#27378) 2026-07-27 01:52:04 -04:00
notifications.py refac 2026-07-27 19:39:36 -04:00
oauth.py refac 2026-07-27 19:39:36 -04:00
payload.py perf: drop the full-payload deepcopy in the OpenAI to Ollama conversion (#27371) 2026-07-27 01:47:23 -04:00
pdf_generator.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
plugin.py refac 2026-07-23 19:17:19 -04:00
rate_limit.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
redis.py fix: Set default Redis socket timeout to None (#27104) 2026-07-27 00:30:00 -04:00
response.py perf: optional orjson JSON codec behind ENABLE_ORJSON (#27583) 2026-07-27 03:45:37 -04:00
sanitize.py refac 2026-03-17 17:58:01 -05:00
security_headers.py perf: stop recomputing static work in per-response ASGI middlewares (#27229) 2026-07-23 12:29:01 -04:00
session_pool.py refac 2026-07-27 04:17:00 -04:00
subagents.py chore: format 2026-07-20 22:11:42 -04:00
task.py refac 2026-06-19 00:16:06 +02:00
terminals.py refac 2026-07-10 18:32:21 -05:00
timers.py fix: scope timer cancellation to the timer's owner (#27472) 2026-07-26 18:12:44 -04:00
tools.py refac 2026-07-27 03:41:08 -04:00
validate.py refac 2026-07-27 19:39:36 -04:00
valves.py refac 2026-06-29 12:29:10 -05:00
webhook.py refac 2026-07-27 19:39:36 -04:00