Slow page load
Hi, Please help me debug a very slow page load using mod_wsgi. I installed django-debug-toolbar and got the following results: ResourceValue User CPU time 1152.072 msec System CPU time 56.004 msec Total CPU time 1208.076 msec Elapsed time1214.114 msec Context switches29 voluntary, 142 involuntary ...while SQL queries says 30 queries in 11.54 msec, so I guess SQL isn't the bottleneck. Could it still be SQL related? my wsgi configuration: WSGIDaemonProcess user processes=2 maximum-requests=500 threads=15 I tried further profiling adding Python's hotshot to debug-toolbar (according to http://backslashn.com/post/505601626/) but I got too much details and can't seem to figure out what to make of it) Any hints or suggestions would be highly appreciated. Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Slow page load
I thought my code was faulty, but the admin interface is also very slow. It takes 8096 msec for a model with 1000 database rows to be opened using the admin interface with debug-toolbar enabled. It is paginated to 100 entries per page, and SQL makes 339 queries in 128.77 msec. I have two foreign keys on this model to models with < 20 entries each. After turning on additional profiling using hotshot/debug toolbar, it takes 61 sec (additional profiling code being run). SQL makes 675 queries in 297.63 msec. Profiling result: 1320805 function calls (1285639 primitive calls) in 12.122 CPU seconds Ordered by: internal time, call count List reduced from 916 to 100 due to restriction <100> ncalls tottime percall cumtime percall filename:lineno(function) 2190942.7900.0003.5760.000 /usr/lib/python2.7/ posixpath.py:130(islink) 2060722.2480.0002.2480.000 /usr/lib/python2.7/ posixpath.py:60(join) 27636/142231.7510.0008.5870.001 /usr/lib/python2.7/ posixpath.py:355(realpath) 2190940.5450.0000.7860.000 /usr/lib/python2.7/ stat.py:55(S_ISLNK) 282940.4940.0000.4940.000 /usr/lib/python2.7/ posixpath.py:312(normpath) 134130.3430.0001.1080.000 /usr/lib/python2.7/ posixpath.py:378(_resolve_link) 145620.3240.0000.3240.000 /usr/lib/python2.7/ linecache.py:43(checkcache) 3390.2530.0018.9100.026 /usr/lib/pymodules/ python2.7/debug_toolbar/panels/sql.py:31(tidy_stacktrace) 2190980.2400.0000.2400.000 /usr/lib/python2.7/ stat.py:24(S_IFMT) 18480/40370.2020.0000.5020.000 /usr/lib/python2.7/ copy.py:145(deepcopy) 3390.1810.0010.5980.002 /usr/lib/python2.7/ traceback.py:280(extract_stack) 559300.1320.0000.1320.000 /usr/lib/python2.7/ posixpath.py:51(isabs) 3010.0940.0000.2930.001 /usr/lib/pymodules/ python2.7/debug_toolbar/panels/sql.py:49(get_template_info) 153930.0750.0000.0750.000 /usr/lib/pymodules/ python2.7/django/utils/functional.py:274(__getattr__) 181380.0750.0000.0750.000 /usr/lib/python2.7/ copy.py:267(_keep_alive) 315850.0720.0000.0720.000 /usr/lib/pymodules/ python2.7/django/views/debug.py:18(linebreak_iter) 3390.0720.000 10.0870.030 /usr/lib/pymodules/ python2.7/debug_toolbar/panels/sql.py:88(execute) 142250.0700.0000.3380.000 /usr/lib/python2.7/ posixpath.py:341(abspath) 2353/20180.0690.0000.2790.000 /usr/lib/pymodules/ python2.7/django/utils/tree.py:55(__deepcopy__) 3110.0640.0000.1280.000 /usr/lib/pymodules/python2.7/ django/template/loaders/app_directories.py:52(load_template_source) 10090.0600.0000.5850.001 /usr/lib/pymodules/ python2.7/django/db/models/sql/query.py:229(clone) 9680.0570.0000.1110.000 /usr/lib/pymodules/ python2.7/django/db/models/base.py:273(__init__) 145620.0540.0000.0930.000 /usr/lib/python2.7/ linecache.py:13(getline) 3390.0520.0000.0520.000 /usr/lib/pymodules/ python2.7/django/db/backends/mysql/base.py:263(_valid_connection) 9376/85570.0500.0004.4110.001 /usr/lib/pymodules/ python2.7/django/utils/encoding.py:54(force_unicode) 3390.0500.0000.0700.000 /usr/lib/pymodules/ python2.7/MySQLdb/cursors.py:273(_do_query) 2689/13440.0500.0000.2330.000 /usr/lib/python2.7/ copy.py:234(_deepcopy_tuple) 63650.0440.0000.0440.000 /usr/lib/python2.7/ encodings/utf_8.py:15(decode) 12000.0410.000 10.7590.009 /usr/lib/pymodules/ python2.7/django/contrib/admin/templatetags/admin_list.py: 129(items_for_result) 9320.0370.000 11.2030.012 /usr/lib/pymodules/ python2.7/django/db/models/fields/related.py:286(__get__) 700/1000.0330.0000.1080.001 /usr/lib/pymodules/ python2.7/django/db/models/query.py:1144(get_cached_row) 27130.0300.0000.0320.000 /usr/lib/pymodules/ python2.7/django/utils/datastructures.py:89(__init__) 4680.0270.0000.0330.000 /usr/lib/pymodules/ python2.7/django/db/backends/mysql/compiler.py:4(resolve_columns) 6000.0260.0000.0440.000 /usr/lib/pymodules/ python2.7/django/contrib/admin/util.py:321(display_for_field) 32310.0250.0000.0250.000 /usr/lib/pymodules/ python2.7/django/utils/safestring.py:89(mark_safe) 145620.0240.0000.0390.000 /usr/lib/python2.7/ linecache.py:33(getlines) 14420.0240.0000.0360.000 /usr/lib/pymodules/ python2.7/django/db/models/options.py:270(get_field) 8060.0230.000 10.6610.013 /usr/lib/pymodules/ python2.7/django/db/models/query.py:212(iterator) 252/10.0220.000 11.084 11.084 /usr/lib/pymodules/ python2.7/dja