Files
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
..
2026-07-01 02:48:29 -05:00
2026-06-29 11:56:00 -05:00
2026-07-27 03:01:19 -04:00
2026-07-23 22:52:23 -04:00
2026-07-27 19:24:03 -04:00
2026-07-27 03:54:05 -04:00
2026-07-31 17:30:47 -04:00
2026-03-17 17:58:01 -05:00
2026-07-23 02:54:56 -04:00
2026-07-26 21:12:14 -04:00
2026-07-24 01:44:30 -04:00
2026-07-27 03:05:26 -04:00
2026-07-23 21:29:33 -04:00
2026-07-27 02:36:15 -04:00
2026-07-27 00:12:47 -04:00
2026-07-27 02:24:41 -04:00
2026-07-27 19:39:36 -04:00
2026-07-27 02:49:08 -04:00
2026-07-26 23:09:22 -04:00
2026-07-27 19:39:36 -04:00
2026-07-27 19:39:36 -04:00
2026-07-23 19:17:19 -04:00
2026-03-17 17:58:01 -05:00
2026-07-27 04:17:00 -04:00
2026-07-20 22:11:42 -04:00
2026-06-19 00:16:06 +02:00
2026-07-10 18:32:21 -05:00
2026-07-27 03:41:08 -04:00
2026-07-27 19:39:36 -04:00
2026-06-29 12:29:10 -05:00
2026-07-27 19:39:36 -04:00