Changes between Initial Version and Version 1 of Ticket #36439, comment 5


Ignore:
Timestamp:
Jun 28, 2025, 9:12:59 AM (2 months ago)
Author:
Roelzkie

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #36439, comment 5

    initial v1  
    33
    44Hello, I see the status of this ticket is **Accepted** without an owner. I wonder if you can allow me to spend time doing a basic profiling for the above-suggested solution, and make a comparison to help with your decision. Thank you.
     5
     6
     7----
     8
     9**EDIT: I made some basic profiling using `cProfile` for 1000 users using an SQLite database.**
     10
     111. **Current**: 94770 function calls (94752 primitive calls) in 251.144 seconds. [https://gist.github.com/roelzkie15/13cb9c0583f0e57e829067cd5dd1dfeb See all logs].
     122. **With sync_to_async**: 407770 function calls (405752 primitive calls) in 251.129 seconds. [https://gist.github.com/roelzkie15/52dd618960b0c1c0da5f1434dea83145 See all logs].
     133. **With ThreadPoolExecutor(4)**: 390842 function calls (389818 primitive calls) in 254.972 seconds for 1000 users. [https://gist.github.com/roelzkie15/07bed634a3b0b8acf4fec740d062e7f8 See all logs].
     144. **With ThreadPoolExecutor(8)**: 390842 function calls (389818 primitive calls) in 251.255 seconds for 1000 users. [https://gist.github.com/roelzkie15/a227700c1abe29e752f52ce95ee2d951 See all logs].
     155. **With ThreadPoolExecutor(12)**: 390842 function calls (389818 primitive calls) in 254.198 seconds for 1000 users. [https://gist.github.com/roelzkie15/a0d69aa3f5f3787e5cf595382ea169e6 See all logs].
     166. **ThreadPoolExecutor(16)**: 390842 function calls (389818 primitive calls) in 254.155 seconds for 1000 users. [https://gist.github.com/roelzkie15/a31768102030ad0e532cd5335b8662a1 See all logs].
     17
     18They're almost has no difference, but I'm not 100% sure if I'm doing it correctly. Below is the python script for profiling:
     19
     20
     21{{{#!python
     22
     23import os
     24
     25import django
     26
     27os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
     28django.setup()
     29
     30# --
     31import asyncio
     32import cProfile
     33
     34from django.contrib.auth.models import User
     35
     36
     37async def main():
     38
     39    profiler = cProfile.Profile()
     40    profiler.enable()
     41
     42    async for user in User.objects.all()[:1000]:
     43        await user.acheck_password(user.username), user.username
     44
     45    profiler.disable()
     46    profiler.print_stats(sort='cumulative')
     47
     48
     49if __name__ == "__main__":
     50    asyncio.run(main())
     51
     52}}}
     53
     54System information:
     55
     56
     57{{{#!shell
     58$ sysctl -a | grep machdep.cpu
     59machdep.cpu.cores_per_package: 8
     60machdep.cpu.core_count: 8
     61machdep.cpu.logical_per_package: 8
     62machdep.cpu.thread_count: 8
     63machdep.cpu.brand_string: Apple M1
     64
     65$ python --version
     66Python 3.13.2
     67
     68$ python -c "import django; print(django.get_version());"
     695.2.3
     70}}}
     71
Back to Top