-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Fixed #36439: Optimize acheck_password
CPU heavy internal hashing process by using a sync_to_async
on verify_password
.
#19611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
3750296
to
1bb5279
Compare
acheck_password
CPU heavy internal hashing process by using a ThreadPoolExecutoracheck_password
CPU heavy internal hashing process by using a ThreadPoolExecutor
b984047
to
c9eec27
Compare
c9eec27
to
d1a1ef1
Compare
d1a1ef1
to
50a6d87
Compare
Based on the ticket, a test may not be needed for this patch. |
50a6d87
to
b5354b5
Compare
acheck_password
CPU heavy internal hashing process by using a ThreadPoolExecutoracheck_password
CPU heavy internal hashing process by using a ThreadPoolExecutor
django/conf/global_settings.py
Outdated
@@ -546,6 +546,8 @@ def gettext_noop(s): | |||
|
|||
AUTH_PASSWORD_VALIDATORS = [] | |||
|
|||
CHECK_PASSWORD_EXECUTOR_MAX_WORKERS = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't add a global setting for something niche within a contrib app
In general adding settings is quite controversial and needs to be discussed and agreed with the wider community
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for checking. If we don't want to control any of the ThreadPoolExecutor
options, we can also rely on its basic instance or maybe create a ThreadPoolExecutor every acheck_password
call, depending on the performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋🏼 @sarahboyce, I made a new performance benchmarking/testing here, and it looks like using sync_to_async
without ThreadPoolExecutor
is enough to optimize the performance.
I also updated the PR's description.
…n `verify_password`.
b5354b5
to
c591c40
Compare
acheck_password
CPU heavy internal hashing process by using a ThreadPoolExecutoracheck_password
CPU heavy internal hashing process by using a sync
acheck_password
CPU heavy internal hashing process by using a syncacheck_password
CPU heavy internal hashing process by using a sync_to_async
on verify_password
.
Trac ticket number
ticket-36439
Branch description
Conducted several experiments/benchmarks on the performance of theacheck_password
that blocks asyncio's event-loop, which is causing a performance bottleneck. Adding aThreadPoolExecutor
significantly improved the performance gap compared to the test without using it.Also, introduced theCHECK_PASSWORD_EXECUTOR_MAX_WORKERS
for allowing developers to provide a configurable setting for theThreadPoolExecutor
instance. See the updated document on this PR.EDIT:
Please check the new experiments/benchmarks on the performance of the
acheck_password
that blocks asyncio's event-loop, which is causing a performance bottleneck by using thesync_to_async
on theverify_password
.This PR targets a patch for v5.2 as mentioned in the ticket.
Checklist
main
branch.