perf: random memory optimizations (#36102)

* perf: preload mysqlclient

Now the default choice instead of PyMySQL.

* perf: Lazy load JWT

OAuth is not used that frequently, on that many sites.

* perf: Lazy load whoosh

Rarely loaded
This commit is contained in:
Ankush Menat 2026-01-20 12:27:19 +05:30 committed by GitHub
parent 8d18a47bad
commit 01c6a55031
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 5 deletions

View file

@ -48,7 +48,7 @@ import frappe.boot
import frappe.client
import frappe.core.doctype.file.file
import frappe.core.doctype.user.user
import frappe.database.mariadb.database # Load database related utils
import frappe.database.mariadb.mysqlclient # Load database related utils
import frappe.database.query
import frappe.desk.desktop # workspace
import frappe.desk.form.save

View file

@ -5,7 +5,6 @@ import re
from http import cookies
from urllib.parse import unquote, urljoin, urlparse
import jwt
from oauthlib.openid import RequestValidator
import frappe
@ -302,6 +301,8 @@ class OAuthWebRequestValidator(RequestValidator):
# OpenID Connect
def finalize_id_token(self, id_token, token, token_handler, request):
import jwt
# Check whether frappe server URL is set
id_token_header = {"typ": "jwt", "alg": "HS256"}
@ -437,6 +438,8 @@ class OAuthWebRequestValidator(RequestValidator):
- OpenIDConnectImplicit
- OpenIDConnectHybrid
"""
import jwt
if id_token_hint:
try:
user = None

View file

@ -2,14 +2,13 @@
# License: MIT. See LICENSE
import frappe
from frappe.search.full_text_search import FullTextSearch
from frappe.search.sqlite_search import SQLiteSearch
from frappe.search.website_search import WebsiteSearch
from frappe.utils import cint
@frappe.whitelist(allow_guest=True)
def web_search(query, scope=None, limit=20):
from frappe.search.website_search import WebsiteSearch
limit = cint(limit)
ws = WebsiteSearch(index_name="web_routes")
return ws.search(query, scope, limit)