From b6e34ace35aa730f37701c7b122916740dc155f9 Mon Sep 17 00:00:00 2001 From: Ariel Rin Date: Sun, 26 May 2024 03:22:08 +0000 Subject: [PATCH] Expand Tuning Doccs --- .pre-commit-config.yaml | 11 +- docker/conf/nginx.conf | 40 +- docker/docker-compose.yml | 4 +- docs/development/custom/framework/api.md | 4 +- .../development/custom/framework/templates.md | 2 +- .../custom/integrating-services.md | 6 +- docs/development/custom/menu-hooks.md | 2 + docs/development/custom/url-hooks.md | 2 + docs/features/services/discord.md | 5 + docs/features/services/nameformats.md | 1 + docs/installation/apache.md | 8 +- docs/maintenance/tuning/gunicorn.md | 13 - docs/maintenance/tuning/python.md | 1148 +++++++++++------ docs/maintenance/tuning/web.md | 156 +++ 14 files changed, 956 insertions(+), 446 deletions(-) delete mode 100644 docs/maintenance/tuning/gunicorn.md create mode 100644 docs/maintenance/tuning/web.md diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index af528d78..04c74b56 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -74,10 +74,15 @@ repos: \.mo| swagger\.json ) - + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.41.0 + hooks: + - id: markdownlint + args: + - --disable=MD013 # Infrastructure - repo: https://github.com/tox-dev/pyproject-fmt - rev: 2.0.3 + rev: 2.1.3 hooks: - id: pyproject-fmt name: pyproject.toml formatter @@ -87,7 +92,7 @@ repos: additional_dependencies: - tox==4.15.0 # https://github.com/tox-dev/tox/releases/latest - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.17 + rev: v0.18 hooks: - id: validate-pyproject name: Validate pyproject.toml diff --git a/docker/conf/nginx.conf b/docker/conf/nginx.conf index 8722c0be..242fb42f 100644 --- a/docker/conf/nginx.conf +++ b/docker/conf/nginx.conf @@ -1,20 +1,28 @@ -server { - listen 80; - location = /favicon.ico { access_log off; log_not_found off; } - location /static { - alias /var/www/myauth/static; - autoindex off; - } +events {} +http { + include mime.types; + default_type application/octet-stream; - location /robots.txt { - alias /var/www/myauth/static/robots.txt; - } + sendfile on; - location / { - proxy_pass http://allianceauth_gunicorn:8000; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_redirect off; + server { + listen 80; + location = /favicon.ico { access_log off; log_not_found off; } + location /static { + alias /var/www/myauth/static; + autoindex off; + } + + location /robots.txt { + alias /var/www/myauth/static/robots.txt; + } + + location / { + proxy_pass http://allianceauth_gunicorn:8000; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_redirect off; + } } } diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 39b9d9aa..1c427652 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -62,10 +62,10 @@ services: max-file: "5" nginx: - image: nginx:1.25 + image: nginx:stable restart: always volumes: - - ./conf/nginx.conf:/etc/nginx/conf.d/default.conf + - ./conf/nginx.conf:/etc/nginx/nginx.conf - static-volume:/var/www/myauth/static depends_on: - allianceauth_gunicorn diff --git a/docs/development/custom/framework/api.md b/docs/development/custom/framework/api.md index b5b12df3..576a5373 100644 --- a/docs/development/custom/framework/api.md +++ b/docs/development/custom/framework/api.md @@ -36,7 +36,7 @@ from allianceauth.framework.api.evecharacter import get_user_from_evecharacter user = get_user_from_evecharacter(character=my_evecharacter) ``` -Now, `user` is a `User` object, or the sentinel username (see [get_sentinel_user](#get-sentinel-user)) +Now, `user` is a `User` object, or the sentinel username (see [get_sentinel_user](#get_sentinel_user)) if the `EveCharacter` has no user. ## User API @@ -88,7 +88,7 @@ main_character = get_main_character_name_from_user(user=my_user) Now, `main_character` is a `string` containing the user's main character name. If the user has no main character, the username will be returned. If the user is `None`, -the sentinel username (see [get_sentinel_user](#get-sentinel-user)) will be returned. +the sentinel username (see [get_sentinel_user](#get_sentinel_user)) will be returned. ### get_sentinel_user diff --git a/docs/development/custom/framework/templates.md b/docs/development/custom/framework/templates.md index 51a5861d..b2308032 100644 --- a/docs/development/custom/framework/templates.md +++ b/docs/development/custom/framework/templates.md @@ -8,7 +8,7 @@ have to load specific CSS or JavaScript yourself. These bundles include DataTables CSS and JS, jQuery Datepicker CSS and JS, jQueryUI CSS and JS, and more. -A full list of bundles we provide can be found here: https://gitlab.com/allianceauth/allianceauth/-/tree/master/allianceauth/templates/bundles +A full list of bundles we provide can be found here: To use a bundle, you can use the following code in your template (Example for jQueryUI): diff --git a/docs/development/custom/integrating-services.md b/docs/development/custom/integrating-services.md index c8975d58..0b156ed6 100644 --- a/docs/development/custom/integrating-services.md +++ b/docs/development/custom/integrating-services.md @@ -122,10 +122,6 @@ class MyService(ServiceHook): All of your apps defined urlpatterns will then be included in the `URLconf` when the core application starts. -#### self.service_ctrl_template - -This is provided as a courtesy and defines the default template to be used with [render_service_ctrl](#render_service_ctrl). You are free to redefine or not use this variable at all. - #### title This is a property which provides a user-friendly display of your service's name. It will usually do a reasonably good job unless your service name has punctuation or odd capitalization. If this is the case, you should override this method and return a string. @@ -134,7 +130,7 @@ This is a property which provides a user-friendly display of your service's name #### self.service_ctrl_template -This is provided as a courtesy and defines the default template to be used with [render_service_ctrl](#render-service-ctrl). You are free to redefine or not use this variable at all. +This is provided as a courtesy and defines the default template to be used with [render_service_ctrl](#render_service_ctrl). You are free to redefine or not use this variable at all. #### delete_user diff --git a/docs/development/custom/menu-hooks.md b/docs/development/custom/menu-hooks.md index 2ff0aed2..580bf055 100644 --- a/docs/development/custom/menu-hooks.md +++ b/docs/development/custom/menu-hooks.md @@ -18,6 +18,8 @@ The `MenuItemHook` class specifies some parameters/instance variables required f :undoc-members: ``` +## Parameters + ### text The text shown as menu item, e.g., usually the name of the app. diff --git a/docs/development/custom/url-hooks.md b/docs/development/custom/url-hooks.md index 4790b1bd..d43fc110 100644 --- a/docs/development/custom/url-hooks.md +++ b/docs/development/custom/url-hooks.md @@ -12,6 +12,8 @@ def register_urls(): return UrlHook(app_name.urls, 'app_name', r^'app_name/') ``` +### Parameters + #### urls The urls module to include. See [the Django docs](https://docs.djangoproject.com/en/dev/topics/http/urls/#example) for designing urlpatterns. diff --git a/docs/features/services/discord.md b/docs/features/services/discord.md index eedaa225..106ac480 100644 --- a/docs/features/services/discord.md +++ b/docs/features/services/discord.md @@ -50,6 +50,7 @@ Update your auth project's settings file, inputting the server ID as `DISCORD_GU :::{note} If you already have a Discord server, skip the creation step, but be sure to retrieve the server ID ::: + ### Registering an Application Navigate to the [Discord Developers site.](https://discord.com/developers/applications/me) Press the plus sign to create a new application. @@ -112,6 +113,7 @@ Role names on Discord are case-sensitive, while reserved group names on Auth are .. seealso:: For more information see :ref:`ref-reserved-group-names`. ``` + ## Tasks The Discord service contains a number of tasks that can be run to manually perform updates to all users. @@ -132,6 +134,7 @@ Name Description `update_all` Update groups, nicknames, usernames of all users ======================== ==================================================== ``` + :::{note} Depending on how many users you have, running these tasks can take considerable time to finish. You can calculate roughly 1 sec per user for all tasks, except update_all, which needs roughly 3 secs per user. ::: @@ -156,6 +159,7 @@ Name Description `DISCORD_TASKS_MAX_RETRIES` max retries of tasks after an error occurred `3` =================================== ============================================================================================= ======= ``` + ## Permissions To use this service, users will require some of the following. @@ -167,6 +171,7 @@ To use this service, users will require some of the following. | discord.access_discord | None | Can Access the Discord Service | +---------------------------------------+------------------+--------------------------------------------------------------------------+ ``` + ## Troubleshooting ### "Unknown Error" on Discord site when activating service diff --git a/docs/features/services/nameformats.md b/docs/features/services/nameformats.md index 059e054d..f7c9f6f4 100644 --- a/docs/features/services/nameformats.md +++ b/docs/features/services/nameformats.md @@ -29,6 +29,7 @@ Currently, the following services support custom name formats: | Xenforo | Username | ``{character_name}`` | +-------------+-----------+-------------------------------------+ ``` + :::{note} It's important to note here, before we get into what you can do with a name formatter, that before the generated name is passed off to the service to create an account it will be sanitized to remove characters (the letters and numbers etc.) that the service cannot support. This means that, despite what you configured, the service may display something different. It is up to you to test your formatter and understand how your format may be disrupted by a certain services sanitization function. ::: diff --git a/docs/installation/apache.md b/docs/installation/apache.md index 4380b4c8..ab911057 100644 --- a/docs/installation/apache.md +++ b/docs/installation/apache.md @@ -11,21 +11,28 @@ If you're using a small VPS to host services with very limited memory, consider ::::{tabs} :::{group-tab} Ubuntu 2004, 2204 + ```shell apt-get install apache2 ``` + ::: :::{group-tab} CentOS 7 + ```shell yum install httpd ``` + ::: :::{group-tab} CentOS Stream 8 + ```shell dnf install httpd ``` + ::: :::{group-tab} CentOS Stream 9 + ```shell systemctl enable httpd systemctl start httpd @@ -36,7 +43,6 @@ systemctl start httpd CentOS 7, Stream 8, Stream 9 - ## Configuration ### Permissions diff --git a/docs/maintenance/tuning/gunicorn.md b/docs/maintenance/tuning/gunicorn.md deleted file mode 100644 index 587e1407..00000000 --- a/docs/maintenance/tuning/gunicorn.md +++ /dev/null @@ -1,13 +0,0 @@ -# Gunicorn - -## Number of workers - -The default installation will have 3 workers configured for Gunicorn. This will be fine on most systems, but if your system as more than one core than you might want to increase the number of workers to get better response times. Note that more workers will also need more RAM though. - -The number you set this to will depend on your own server environment, how many visitors you have etc. Gunicorn suggests `(2 x $num_cores) + 1` for the number of workers. So for example, if you have 2 cores, you want 2 x 2 + 1 = 5 workers. See [here](https://docs.gunicorn.org/en/stable/design.html#how-many-workers) for the official discussion on this topic. - -For example, to get 5 workers change the setting `--workers=5` in your `supervisor.conf` file and then reload the supervisor with the following command to activate the change (Ubuntu): - -```shell -systemctl restart supervisor -``` diff --git a/docs/maintenance/tuning/python.md b/docs/maintenance/tuning/python.md index 1ac87f17..73039479 100644 --- a/docs/maintenance/tuning/python.md +++ b/docs/maintenance/tuning/python.md @@ -8,626 +8,968 @@ As a general rule, Python 3.9 and Python 3.11 both had a strong focus on perform [Djangobench](https://github.com/django/djangobench/tree/master) is the source of synthetic benchmarks and a useful tool for running comparisons. Below are some examples to inform your investigations. -Keep in mind while a 1.2x faster result is significant, it's only one step of the process, Celery, SQL, Redis, and many other factors will influence the endresult, and this _python_ speed improvement will not translate 1:1 into real world performance. +Keep in mind while a 1.2x faster result is significant, it's only one step of the process, Celery, SQL, Redis, and many other factors will influence the end result, and this _python_ speed improvement will not translate 1:1 into real world performance. -### Django 4.0.10 - -- Djangobench 0.10.0 -- Django 4.0.10 -- Python 3.8.18 vs Python 3.11.5 +### Running Djangobench ```bash -joel@METABOX:~/djangobench/django$ djangobench --vcs=none --control=. --experiment=. --control-python=/home/joel/djangobench/py38/bin/python --experiment-python=/home/joel/djangobench/py311/bin/python -r /home/joel/djangobench/results -t 500 +python3.8 -m venv py38 +python3.11 -m venv py311 +pip install -e git://github.com/django/djangobench.git#egg=djangobench +git clone https://github.com/django/django.git +cd django +djangobench --control=x --experiment=x --control-python=x --experiment-python=x -r /home/ozira/djangobench/results -t 500 +``` + +### Django 4.2.13 Py38 v Py311 + +- Djangobench 0.10.0 +- Django 4.2.13 +- Python 3.8.19 vs Python 3.11.5 + +```bash +python3.8 -m venv py38 +python3.11 -m venv py38 +pip install -e git://github.com/django/djangobench.git#egg=djangobench +git clone https://github.com/django/django.git +cd django + +ozira@METABOX:~/djangobench/django$ djangobench --control=4.2.13 --experiment=4.2.13 --control-python=/home/ozira/djangobench/py38/bin/python --experiment-python=/home/ozira/djangobench/py311/bin/python -r /home/ozira/djangobench/results -t 500 Running all benchmarks -Recording data to '/home/joel/djangobench/results' -Control: Django 4.0.10 (in .) -Experiment: Django 4.0.10 (in .) +Recording data to '/home/ozira/djangobench/results' +Control: Django 4.2 (in git branch 4.2) +Experiment: Django 4.2 (in git branch 4.2) Running 'multi_value_dict' benchmark ... -Min: 0.000014 -> 0.000013: 1.0304x faster -Avg: 0.000183 -> 0.000133: 1.3698x faster -Significant (t=9.325958) -Stddev: 0.00010 -> 0.00007: 1.3791x smaller (N = 500) +Min: 0.000016 -> 0.000014: 1.1215x faster +Avg: 0.000212 -> 0.000158: 1.3378x faster +Significant (t=8.313771) +Stddev: 0.00012 -> 0.00008: 1.3703x smaller (N = 500) Running 'query_values' benchmark ... -Min: 0.000079 -> 0.000070: 1.1308x faster -Avg: 0.000084 -> 0.000074: 1.1267x faster -Significant (t=19.174361) -Stddev: 0.00001 -> 0.00001: 1.0255x larger (N = 500) +Min: 0.000096 -> 0.000083: 1.1540x faster +Avg: 0.000100 -> 0.000087: 1.1391x faster +Significant (t=20.039719) +Stddev: 0.00001 -> 0.00001: 1.0402x smaller (N = 500) Running 'query_delete' benchmark ... -Min: 0.000082 -> 0.000074: 1.1145x faster -Avg: 0.000086 -> 0.000078: 1.0987x faster -Significant (t=17.504085) -Stddev: 0.00001 -> 0.00001: 1.1888x smaller (N = 500) +Min: 0.000089 -> 0.000077: 1.1555x faster +Avg: 0.000094 -> 0.000082: 1.1492x faster +Significant (t=24.020715) +Stddev: 0.00001 -> 0.00001: 1.0738x smaller (N = 500) Running 'query_select_related' benchmark ... -Min: 0.016771 -> 0.013520: 1.2405x faster -Avg: 0.017897 -> 0.014149: 1.2649x faster -Significant (t=40.942990) -Stddev: 0.00190 -> 0.00077: 2.4535x smaller (N = 500) +Min: 0.021098 -> 0.017898: 1.1788x faster +Avg: 0.027279 -> 0.019895: 1.3712x faster +Significant (t=31.103306) +Stddev: 0.00486 -> 0.00213: 2.2832x smaller (N = 500) Running 'query_aggregate' benchmark ... -Min: 0.000092 -> 0.000083: 1.1105x faster -Avg: 0.000100 -> 0.000090: 1.1107x faster -Significant (t=9.967204) -Stddev: 0.00002 -> 0.00001: 1.5003x smaller (N = 500) +Min: 0.000162 -> 0.000140: 1.1626x faster +Avg: 0.000184 -> 0.000153: 1.2025x faster +Significant (t=20.672411) +Stddev: 0.00003 -> 0.00002: 1.2643x smaller (N = 500) Running 'query_raw_deferred' benchmark ... -Min: 0.004157 -> 0.003563: 1.1666x faster -Avg: 0.004626 -> 0.003809: 1.2143x faster -Significant (t=12.325104) -Stddev: 0.00121 -> 0.00086: 1.4047x smaller (N = 500) +Min: 0.005456 -> 0.004688: 1.1637x faster +Avg: 0.006070 -> 0.005151: 1.1786x faster +Significant (t=10.912514) +Stddev: 0.00155 -> 0.00107: 1.4503x smaller (N = 500) Running 'query_get_or_create' benchmark ... -Min: 0.000412 -> 0.000362: 1.1385x faster -Avg: 0.000458 -> 0.000407: 1.1259x faster -Significant (t=14.169322) -Stddev: 0.00006 -> 0.00005: 1.1306x smaller (N = 500) +Min: 0.000526 -> 0.000457: 1.1526x faster +Avg: 0.000597 -> 0.000546: 1.0946x faster +Significant (t=7.469654) +Stddev: 0.00010 -> 0.00012: 1.1192x larger (N = 500) Running 'query_values_list' benchmark ... -Min: 0.000080 -> 0.000071: 1.1231x faster -Avg: 0.000089 -> 0.000076: 1.1706x faster -Significant (t=18.298942) -Stddev: 0.00001 -> 0.00001: 1.9398x smaller (N = 500) +Min: 0.000102 -> 0.000090: 1.1403x faster +Avg: 0.000113 -> 0.000096: 1.1733x faster +Significant (t=13.975856) +Stddev: 0.00002 -> 0.00001: 2.0715x smaller (N = 500) Running 'url_resolve_flat_i18n_off' benchmark ... -Min: 0.055764 -> 0.045370: 1.2291x faster -Avg: 0.057670 -> 0.047020: 1.2265x faster -Significant (t=111.187780) -Stddev: 0.00206 -> 0.00059: 3.4618x smaller (N = 500) +Min: 0.069399 -> 0.058137: 1.1937x faster +Avg: 0.074039 -> 0.064810: 1.1424x faster +Significant (t=21.837249) +Stddev: 0.00341 -> 0.00881: 2.5880x larger (N = 500) Running 'qs_filter_chaining' benchmark ... -Min: 0.000236 -> 0.000196: 1.2034x faster -Avg: 0.000248 -> 0.000206: 1.2041x faster -Significant (t=44.893544) -Stddev: 0.00002 -> 0.00001: 1.0833x smaller (N = 500) +Min: 0.000304 -> 0.000263: 1.1583x faster +Avg: 0.000321 -> 0.000281: 1.1424x faster +Significant (t=15.363420) +Stddev: 0.00003 -> 0.00005: 1.8538x larger (N = 500) Running 'template_render' benchmark ... -Min: 0.000933 -> 0.000712: 1.3110x faster -Avg: 0.001003 -> 0.000777: 1.2909x faster -Significant (t=8.379095) -Stddev: 0.00043 -> 0.00042: 1.0287x smaller (N = 500) +Min: 0.001211 -> 0.000970: 1.2490x faster +Avg: 0.001471 -> 0.001360: 1.0816x faster +Significant (t=2.688854) +Stddev: 0.00067 -> 0.00064: 1.0463x smaller (N = 500) Running 'query_get' benchmark ... -Min: 0.000259 -> 0.000230: 1.1259x faster -Avg: 0.000282 -> 0.000238: 1.1829x faster -Significant (t=42.267305) -Stddev: 0.00002 -> 0.00001: 1.7842x smaller (N = 500) +Min: 0.000340 -> 0.000295: 1.1554x faster +Avg: 0.000382 -> 0.000324: 1.1797x faster +Significant (t=26.055010) +Stddev: 0.00004 -> 0.00003: 1.5530x smaller (N = 500) Running 'query_none' benchmark ... -Min: 0.000053 -> 0.000045: 1.1830x faster -Avg: 0.000056 -> 0.000049: 1.1449x faster -Significant (t=16.426843) -Stddev: 0.00001 -> 0.00001: 1.1267x larger (N = 500) +Min: 0.000082 -> 0.000074: 1.1133x faster +Avg: 0.000089 -> 0.000081: 1.0934x faster +Significant (t=2.334959) +Stddev: 0.00005 -> 0.00005: 1.0667x larger (N = 500) Running 'query_complex_filter' benchmark ... -Min: 0.000039 -> 0.000034: 1.1527x faster -Avg: 0.000041 -> 0.000037: 1.1091x faster -Significant (t=13.582718) -Stddev: 0.00000 -> 0.00001: 1.5373x larger (N = 500) +Min: 0.000050 -> 0.000053: 1.0480x slower +Avg: 0.000055 -> 0.000058: 1.0495x slower +Significant (t=-3.073848) +Stddev: 0.00001 -> 0.00001: 1.0593x larger (N = 500) Running 'query_filter' benchmark ... -Min: 0.000127 -> 0.000112: 1.1288x faster -Avg: 0.000133 -> 0.000119: 1.1228x faster -Significant (t=22.727829) -Stddev: 0.00001 -> 0.00001: 1.1771x smaller (N = 500) +Min: 0.000169 -> 0.000157: 1.0758x faster +Avg: 0.000186 -> 0.000173: 1.0756x faster +Significant (t=9.677659) +Stddev: 0.00002 -> 0.00002: 1.0462x smaller (N = 500) Running 'template_render_simple' benchmark ... -Min: 0.000030 -> 0.000024: 1.2405x faster -Avg: 0.000035 -> 0.000029: 1.2042x faster +Min: 0.000039 -> 0.000034: 1.1694x faster +Avg: 0.000046 -> 0.000040: 1.1437x faster Not significant -Stddev: 0.00007 -> 0.00005: 1.3190x smaller (N = 500) +Stddev: 0.00010 -> 0.00008: 1.2071x smaller (N = 500) Running 'default_middleware' benchmark ... -Min: -0.000047 -> -0.000054: 0.8624x faster -Avg: 0.000017 -> 0.000017: 1.0032x faster +Min: -0.000061 -> -0.000088: 0.6901x faster +Avg: 0.000002 -> 0.000001: 2.1933x faster Not significant -Stddev: 0.00037 -> 0.00037: 1.0091x larger (N = 500) +Stddev: 0.00003 -> 0.00002: 1.5573x smaller (N = 500) Running 'query_annotate' benchmark ... -Min: 0.000186 -> 0.000162: 1.1505x faster -Avg: 0.000207 -> 0.000178: 1.1660x faster -Significant (t=16.516089) -Stddev: 0.00003 -> 0.00003: 1.1403x smaller (N = 500) +Min: 0.000237 -> 0.000216: 1.0986x faster +Avg: 0.000279 -> 0.000252: 1.1089x faster +Significant (t=9.006132) +Stddev: 0.00006 -> 0.00004: 1.6353x smaller (N = 500) Running 'raw_sql' benchmark ... -Min: 0.000015 -> 0.000013: 1.1070x faster -Avg: 0.000017 -> 0.000014: 1.1676x faster -Significant (t=13.598519) -Stddev: 0.00000 -> 0.00000: 2.3503x smaller (N = 500) +Min: 0.000021 -> 0.000014: 1.4549x faster +Avg: 0.000022 -> 0.000015: 1.4636x faster +Significant (t=30.661315) +Stddev: 0.00000 -> 0.00000: 2.1050x smaller (N = 500) Running 'url_resolve_flat' benchmark ... -Min: 0.056378 -> 0.044772: 1.2592x faster -Avg: 0.058268 -> 0.046656: 1.2489x faster -Significant (t=197.176590) -Stddev: 0.00121 -> 0.00051: 2.3665x smaller (N = 500) +Min: 0.069107 -> 0.056678: 1.2193x faster +Avg: 0.076299 -> 0.066199: 1.1526x faster +Significant (t=16.072616) +Stddev: 0.00711 -> 0.01212: 1.7039x larger (N = 500) Running 'l10n_render' benchmark ... -Min: 0.001097 -> 0.000727: 1.5092x faster -Avg: 0.001160 -> 0.000768: 1.5101x faster -Significant (t=36.971179) -Stddev: 0.00019 -> 0.00014: 1.2946x smaller (N = 500) +Min: 0.002025 -> 0.001557: 1.3009x faster +Avg: 0.002215 -> 0.001671: 1.3258x faster +Significant (t=23.802622) +Stddev: 0.00045 -> 0.00025: 1.7786x smaller (N = 500) Running 'query_count' benchmark ... -Min: 0.000083 -> 0.000073: 1.1302x faster -Avg: 0.000091 -> 0.000079: 1.1640x faster -Significant (t=15.049336) -Stddev: 0.00002 -> 0.00001: 1.6661x smaller (N = 500) +Min: 0.000145 -> 0.000130: 1.1209x faster +Avg: 0.000165 -> 0.000148: 1.1163x faster +Significant (t=6.919972) +Stddev: 0.00005 -> 0.00003: 1.5444x smaller (N = 500) Running 'model_delete' benchmark ... -Min: 0.000123 -> 0.000105: 1.1701x faster -Avg: 0.000135 -> 0.000119: 1.1396x faster -Significant (t=17.781816) -Stddev: 0.00001 -> 0.00002: 1.1990x larger (N = 500) +Min: 0.000148 -> 0.000123: 1.2062x faster +Avg: 0.000172 -> 0.000138: 1.2410x faster +Significant (t=27.181750) +Stddev: 0.00002 -> 0.00002: 1.1414x smaller (N = 500) Running 'query_iterator' benchmark ... -Min: 0.000102 -> 0.000088: 1.1605x faster -Avg: 0.000108 -> 0.000093: 1.1598x faster -Significant (t=23.872009) -Stddev: 0.00001 -> 0.00001: 1.1366x smaller (N = 500) +Min: 0.000189 -> 0.000109: 1.7400x faster +Avg: 0.000208 -> 0.000118: 1.7557x faster +Significant (t=49.768122) +Stddev: 0.00003 -> 0.00002: 1.5989x smaller (N = 500) Running 'template_compilation' benchmark ... -Min: 0.000155 -> 0.000129: 1.2015x faster -Avg: 0.000169 -> 0.000137: 1.2317x faster -Significant (t=6.119618) -Stddev: 0.00009 -> 0.00007: 1.4162x smaller (N = 500) +Min: 0.000206 -> 0.000173: 1.1888x faster +Avg: 0.000223 -> 0.000219: 1.0169x faster +Not significant +Stddev: 0.00011 -> 0.00011: 1.0781x smaller (N = 500) Running 'query_all_multifield' benchmark ... -Min: 0.014582 -> 0.012509: 1.1658x faster -Avg: 0.015715 -> 0.013337: 1.1783x faster -Significant (t=19.183517) -Stddev: 0.00207 -> 0.00184: 1.1241x smaller (N = 500) +Min: 0.018550 -> 0.015556: 1.1925x faster +Avg: 0.021732 -> 0.017870: 1.2161x faster +Significant (t=17.544643) +Stddev: 0.00371 -> 0.00324: 1.1438x smaller (N = 500) Running 'query_prefetch_related' benchmark ... -Min: 0.014293 -> 0.012157: 1.1758x faster -Avg: 0.015467 -> 0.013276: 1.1650x faster -Significant (t=20.607411) -Stddev: 0.00176 -> 0.00160: 1.0952x smaller (N = 500) +Min: 0.017945 -> 0.015631: 1.1480x faster +Avg: 0.021111 -> 0.018532: 1.1391x faster +Significant (t=12.174441) +Stddev: 0.00352 -> 0.00316: 1.1143x smaller (N = 500) Running 'query_all_converters' benchmark ... -Min: 0.000536 -> 0.000464: 1.1554x faster -Avg: 0.000563 -> 0.000486: 1.1595x faster -Significant (t=38.503433) -Stddev: 0.00004 -> 0.00002: 1.6468x smaller (N = 500) +Min: 0.000639 -> 0.000543: 1.1774x faster +Avg: 0.000693 -> 0.000583: 1.1878x faster +Significant (t=32.728842) +Stddev: 0.00004 -> 0.00006: 1.4338x larger (N = 500) Running 'query_distinct' benchmark ... -Min: 0.000106 -> 0.000092: 1.1583x faster -Avg: 0.000127 -> 0.000096: 1.3223x faster -Significant (t=27.798102) -Stddev: 0.00002 -> 0.00001: 3.7187x smaller (N = 500) +Min: 0.000132 -> 0.000138: 1.0442x slower +Avg: 0.000138 -> 0.000149: 1.0834x slower +Significant (t=-11.713427) +Stddev: 0.00002 -> 0.00002: 1.0455x larger (N = 500) Running 'query_dates' benchmark ... -Min: 0.000249 -> 0.000209: 1.1953x faster -Avg: 0.000275 -> 0.000228: 1.2056x faster -Significant (t=30.785168) -Stddev: 0.00003 -> 0.00002: 1.0854x smaller (N = 500) +Min: 0.000426 -> 0.000372: 1.1440x faster +Avg: 0.000479 -> 0.000430: 1.1135x faster +Significant (t=15.165974) +Stddev: 0.00005 -> 0.00006: 1.2095x larger (N = 500) Running 'model_save_existing' benchmark ... -Min: 0.003526 -> 0.003094: 1.1397x faster -Avg: 0.003723 -> 0.003212: 1.1591x faster -Significant (t=47.274918) -Stddev: 0.00018 -> 0.00016: 1.1817x smaller (N = 500) +Min: 0.004182 -> 0.003730: 1.1212x faster +Avg: 0.004460 -> 0.004028: 1.1073x faster +Significant (t=33.972394) +Stddev: 0.00019 -> 0.00021: 1.0838x larger (N = 500) Running 'query_delete_related' benchmark ... -Min: 0.000120 -> 0.000103: 1.1655x faster -Avg: 0.000132 -> 0.000111: 1.1815x faster -Significant (t=6.428771) -Stddev: 0.00005 -> 0.00004: 1.2149x smaller (N = 500) +Min: 0.000140 -> 0.000126: 1.1047x faster +Avg: 0.000159 -> 0.000143: 1.1088x faster +Significant (t=3.361755) +Stddev: 0.00006 -> 0.00009: 1.4858x larger (N = 500) Running 'url_reverse' benchmark ... -Min: 0.000062 -> 0.000060: 1.0318x faster -Avg: 0.000072 -> 0.000068: 1.0622x faster +Min: 0.000072 -> 0.000099: 1.3810x slower +Avg: 0.000104 -> 0.000112: 1.0749x slower Not significant -Stddev: 0.00006 -> 0.00005: 1.0531x smaller (N = 500) +Stddev: 0.00033 -> 0.00008: 3.9995x smaller (N = 500) Running 'query_latest' benchmark ... -Min: 0.000136 -> 0.000118: 1.1454x faster -Avg: 0.000155 -> 0.000129: 1.2008x faster -Significant (t=8.372115) -Stddev: 0.00007 -> 0.00001: 5.1365x smaller (N = 500) +Min: 0.000177 -> 0.000150: 1.1805x faster +Avg: 0.000199 -> 0.000167: 1.1891x faster +Significant (t=16.579351) +Stddev: 0.00003 -> 0.00003: 1.2223x smaller (N = 500) Running 'form_create' benchmark ... -Min: 0.000015 -> 0.000013: 1.2319x faster -Avg: 0.000019 -> 0.000015: 1.2739x faster -Significant (t=4.158080) -Stddev: 0.00002 -> 0.00001: 1.1449x smaller (N = 500) +Min: 0.000018 -> 0.000015: 1.1897x faster +Avg: 0.000024 -> 0.000018: 1.3592x faster +Significant (t=4.264451) +Stddev: 0.00003 -> 0.00002: 1.3397x smaller (N = 500) Running 'query_update' benchmark ... -Min: 0.000047 -> 0.000041: 1.1323x faster -Avg: 0.000052 -> 0.000044: 1.1721x faster -Significant (t=18.470635) -Stddev: 0.00001 -> 0.00000: 1.6104x smaller (N = 500) +Min: 0.000062 -> 0.000047: 1.3306x faster +Avg: 0.000067 -> 0.000053: 1.2660x faster +Significant (t=25.960527) +Stddev: 0.00001 -> 0.00001: 1.2136x larger (N = 500) Running 'query_in_bulk' benchmark ... -Min: 0.000152 -> 0.000136: 1.1193x faster -Avg: 0.000173 -> 0.000147: 1.1735x faster -Significant (t=16.901845) -Stddev: 0.00003 -> 0.00001: 2.1199x smaller (N = 500) +Min: 0.000196 -> 0.000183: 1.0695x faster +Avg: 0.000238 -> 0.000212: 1.1222x faster +Significant (t=9.208556) +Stddev: 0.00005 -> 0.00004: 1.0293x smaller (N = 500) Running 'url_resolve_nested' benchmark ... -Min: 0.000043 -> 0.000034: 1.2871x faster -Avg: 0.000075 -> 0.000047: 1.6049x faster +Min: 0.000058 -> 0.000047: 1.2381x faster +Avg: 0.000094 -> 0.000060: 1.5585x faster Not significant -Stddev: 0.00066 -> 0.00023: 2.8387x smaller (N = 500) +Stddev: 0.00047 -> 0.00020: 2.2921x smaller (N = 500) Running 'model_creation' benchmark ... -Min: 0.000077 -> 0.000066: 1.1579x faster -Avg: 0.000088 -> 0.000072: 1.2205x faster -Significant (t=10.514202) -Stddev: 0.00003 -> 0.00001: 3.1410x smaller (N = 500) +Min: 0.000086 -> 0.000071: 1.2232x faster +Avg: 0.000096 -> 0.000080: 1.1972x faster +Significant (t=5.528555) +Stddev: 0.00004 -> 0.00005: 1.1460x larger (N = 500) Running 'query_order_by' benchmark ... -Min: 0.000135 -> 0.000124: 1.0945x faster -Avg: 0.000145 -> 0.000133: 1.0902x faster -Significant (t=13.574502) -Stddev: 0.00001 -> 0.00001: 1.1586x smaller (N = 500) +Min: 0.000180 -> 0.000153: 1.1761x faster +Avg: 0.000192 -> 0.000168: 1.1406x faster +Significant (t=14.472948) +Stddev: 0.00002 -> 0.00003: 1.0888x larger (N = 500) Running 'startup' benchmark ... Skipped: Django 1.9 and later has changed app loading. This benchmark needs fixing anyway. Running 'form_clean' benchmark ... -Min: 0.000005 -> 0.000003: 1.4696x faster -Avg: 0.000006 -> 0.000004: 1.4931x faster -Significant (t=11.263253) -Stddev: 0.00000 -> 0.00000: 2.2571x smaller (N = 500) +Min: 0.000006 -> 0.000005: 1.2056x faster +Avg: 0.000006 -> 0.000006: 1.1728x faster +Significant (t=5.893457) +Stddev: 0.00000 -> 0.00000: 1.4504x larger (N = 500) Running 'locale_from_request' benchmark ... -Min: 0.000076 -> 0.000082: 1.0895x slower -Avg: 0.000083 -> 0.000090: 1.0877x slower -Not significant -Stddev: 0.00009 -> 0.00006: 1.6230x smaller (N = 500) +Min: 0.000122 -> 0.000113: 1.0747x faster +Avg: 0.000130 -> 0.000119: 1.0879x faster +Significant (t=2.108857) +Stddev: 0.00009 -> 0.00007: 1.2298x smaller (N = 500) Running 'query_exists' benchmark ... -Min: 0.000243 -> 0.000214: 1.1399x faster -Avg: 0.000262 -> 0.000227: 1.1571x faster -Significant (t=27.797738) -Stddev: 0.00002 -> 0.00002: 1.2601x smaller (N = 500) +Min: 0.000411 -> 0.000351: 1.1700x faster +Avg: 0.000472 -> 0.000406: 1.1616x faster +Significant (t=20.906891) +Stddev: 0.00005 -> 0.00004: 1.2381x smaller (N = 500) Running 'query_values_10000' benchmark ... -Min: 0.005755 -> 0.005269: 1.0923x faster -Avg: 0.006184 -> 0.005587: 1.1067x faster -Significant (t=10.895954) -Stddev: 0.00094 -> 0.00079: 1.1902x smaller (N = 500) +Min: 0.006930 -> 0.006720: 1.0312x faster +Avg: 0.008118 -> 0.007403: 1.0966x faster +Significant (t=8.797671) +Stddev: 0.00137 -> 0.00119: 1.1526x smaller (N = 500) Running 'query_exclude' benchmark ... -Min: 0.000159 -> 0.000141: 1.1256x faster -Avg: 0.000177 -> 0.000151: 1.1741x faster -Significant (t=23.556200) -Stddev: 0.00002 -> 0.00001: 1.8250x smaller (N = 500) +Min: 0.000197 -> 0.000166: 1.1884x faster +Avg: 0.000220 -> 0.000183: 1.2010x faster +Significant (t=22.491738) +Stddev: 0.00003 -> 0.00002: 1.2009x smaller (N = 500) Running 'query_raw' benchmark ... -Min: 0.005619 -> 0.004860: 1.1562x faster -Avg: 0.006181 -> 0.005041: 1.2263x faster -Significant (t=18.008590) -Stddev: 0.00121 -> 0.00074: 1.6376x smaller (N = 500) +Min: 0.006850 -> 0.005836: 1.1739x faster +Avg: 0.007724 -> 0.006518: 1.1851x faster +Significant (t=13.372258) +Stddev: 0.00168 -> 0.00111: 1.5089x smaller (N = 500) Running 'url_resolve' benchmark ... -Min: 0.004666 -> 0.004233: 1.1023x faster -Avg: 0.004920 -> 0.004347: 1.1318x faster -Significant (t=24.865249) -Stddev: 0.00049 -> 0.00016: 3.1507x smaller (N = 500) +Min: 0.006464 -> 0.005129: 1.2602x faster +Avg: 0.006980 -> 0.005578: 1.2512x faster +Significant (t=62.894242) +Stddev: 0.00044 -> 0.00023: 1.8763x smaller (N = 500) Running 'model_save_new' benchmark ... -Min: 0.003420 -> 0.003105: 1.1014x faster -Avg: 0.003610 -> 0.003217: 1.1221x faster -Significant (t=42.956103) -Stddev: 0.00017 -> 0.00011: 1.6304x smaller (N = 500) +Min: 0.004156 -> 0.003608: 1.1519x faster +Avg: 0.004399 -> 0.003921: 1.1220x faster +Significant (t=31.848867) +Stddev: 0.00022 -> 0.00026: 1.1820x larger (N = 500) Running 'query_all' benchmark ... -Min: 0.008101 -> 0.007077: 1.1447x faster -Avg: 0.009006 -> 0.007936: 1.1348x faster -Significant (t=9.981534) -Stddev: 0.00171 -> 0.00168: 1.0215x smaller (N = 500) +Min: 0.009951 -> 0.008729: 1.1399x faster +Avg: 0.011392 -> 0.010135: 1.1240x faster +Significant (t=7.913017) +Stddev: 0.00257 -> 0.00246: 1.0449x smaller (N = 500) ``` -### Django 4.2.6 +### Django 4.2.13 Py311 v Py312 - Djangobench 0.10.0 -- Django 4.0.10 -- Python 3.8.18 vs Python 3.11.5 +- Django 4.2.13 +- Python 3.11.9 vs Python 3.12.3 ```bash -joel@METABOX:~/djangobench/django$ djangobench --vcs=none --control=. --experiment=. --control-python=/home/joel/djangobench/py38/bin/python --experiment-python=/home/joel/djangobench/py311/bin/python -r /home/joel/djangobench/results -t 500 +python3.8 -m venv py38 +python3.11 -m venv py38 +pip install -e git://github.com/django/djangobench.git#egg=djangobench +git clone https://github.com/django/django.git +cd django + +ozira@METABOX:~/djangobench/django$ djangobench --control=4.2.13 --experiment=4.2.13 --control-python=/home/ozira/djangobench/py311/bin/python --experiment-python=/home/ozira/djangobench/py312/bin/python -r /home/ozira/djangobench/results -t 500 Running all benchmarks -Recording data to '/home/joel/djangobench/results' -Control: Django 4.2.6 (in .) -Experiment: Django 4.2.6 (in .) +Recording data to '/home/ozira/djangobench/results' +Control: Django 4.2.13 (in git branch 4.2.13) +Experiment: Django 4.2.13 (in git branch 4.2.13) Running 'multi_value_dict' benchmark ... -Min: -0.000004 -> 0.000013: -3.0336x slower -Avg: 0.000182 -> 0.000133: 1.3680x faster -Significant (t=9.151616) -Stddev: 0.00010 -> 0.00007: 1.3826x smaller (N = 500) +Min: 0.000015 -> 0.000012: 1.2159x faster +Avg: 0.000153 -> 0.000145: 1.0567x faster +Not significant +Stddev: 0.00008 -> 0.00008: 1.0399x smaller (N = 500) Running 'query_values' benchmark ... -Min: 0.000082 -> 0.000072: 1.1485x faster -Avg: 0.000086 -> 0.000075: 1.1462x faster -Significant (t=30.114973) -Stddev: 0.00001 -> 0.00001: 1.0258x larger (N = 500) +Min: 0.000080 -> 0.000074: 1.0884x faster +Avg: 0.000086 -> 0.000080: 1.0848x faster +Significant (t=9.315400) +Stddev: 0.00001 -> 0.00001: 1.3002x larger (N = 500) Running 'query_delete' benchmark ... -Min: 0.000080 -> 0.000071: 1.1169x faster -Avg: 0.000086 -> 0.000077: 1.1088x faster -Significant (t=13.459411) -Stddev: 0.00001 -> 0.00001: 1.0008x smaller (N = 500) +Min: 0.000076 -> 0.000073: 1.0437x faster +Avg: 0.000082 -> 0.000078: 1.0473x faster +Significant (t=6.287296) +Stddev: 0.00001 -> 0.00001: 1.2237x smaller (N = 500) Running 'query_select_related' benchmark ... -Min: 0.016889 -> 0.013513: 1.2498x faster -Avg: 0.018370 -> 0.013885: 1.3230x faster -Significant (t=48.921967) -Stddev: 0.00196 -> 0.00061: 3.2174x smaller (N = 500) +Min: 0.015799 -> 0.015198: 1.0395x faster +Avg: 0.017664 -> 0.016664: 1.0600x faster +Significant (t=12.493385) +Stddev: 0.00129 -> 0.00124: 1.0404x smaller (N = 500) Running 'query_aggregate' benchmark ... -Min: 0.000167 -> 0.000153: 1.0904x faster -Avg: 0.000182 -> 0.000165: 1.1029x faster -Significant (t=12.685517) -Stddev: 0.00002 -> 0.00002: 1.3019x smaller (N = 500) +Min: 0.000180 -> 0.000170: 1.0605x faster +Avg: 0.000196 -> 0.000202: 1.0290x slower +Significant (t=-3.095949) +Stddev: 0.00002 -> 0.00003: 1.6034x larger (N = 500) Running 'query_raw_deferred' benchmark ... -Min: 0.004160 -> 0.003674: 1.1323x faster -Avg: 0.004596 -> 0.003888: 1.1820x faster -Significant (t=11.504156) -Stddev: 0.00117 -> 0.00073: 1.5957x smaller (N = 500) +Min: 0.004605 -> 0.003799: 1.2122x faster +Avg: 0.005051 -> 0.004491: 1.1246x faster +Significant (t=7.096110) +Stddev: 0.00099 -> 0.00146: 1.4821x larger (N = 500) Running 'query_get_or_create' benchmark ... -Min: 0.000421 -> 0.000356: 1.1823x faster -Avg: 0.000470 -> 0.000392: 1.2011x faster -Significant (t=14.613017) -Stddev: 0.00008 -> 0.00009: 1.0954x larger (N = 500) +Min: 0.000407 -> 0.000441: 1.0838x slower +Avg: 0.000467 -> 0.000504: 1.0794x slower +Significant (t=-6.031826) +Stddev: 0.00009 -> 0.00010: 1.1220x larger (N = 500) Running 'query_values_list' benchmark ... -Min: 0.000080 -> 0.000070: 1.1395x faster -Avg: 0.000085 -> 0.000075: 1.1202x faster -Significant (t=20.300988) -Stddev: 0.00001 -> 0.00001: 1.0537x smaller (N = 500) +Min: 0.000079 -> 0.000078: 1.0091x faster +Avg: 0.000085 -> 0.000085: 1.0028x slower +Not significant +Stddev: 0.00001 -> 0.00001: 1.5801x larger (N = 500) Running 'url_resolve_flat_i18n_off' benchmark ... -Min: 0.056031 -> 0.045854: 1.2219x faster -Avg: 0.057048 -> 0.048370: 1.1794x faster -Significant (t=106.668460) -Stddev: 0.00117 -> 0.00139: 1.1819x larger (N = 500) +Min: 0.054191 -> 0.052512: 1.0320x faster +Avg: 0.062988 -> 0.056872: 1.1075x faster +Significant (t=14.068836) +Stddev: 0.00854 -> 0.00465: 1.8373x smaller (N = 500) Running 'qs_filter_chaining' benchmark ... -Min: 0.000247 -> 0.000205: 1.2080x faster -Avg: 0.000267 -> 0.000219: 1.2211x faster -Significant (t=38.507950) -Stddev: 0.00002 -> 0.00002: 1.0252x larger (N = 500) +Min: 0.000253 -> 0.000233: 1.0868x faster +Avg: 0.000274 -> 0.000251: 1.0890x faster +Significant (t=12.292236) +Stddev: 0.00003 -> 0.00003: 1.2192x smaller (N = 500) Running 'template_render' benchmark ... -Min: 0.000956 -> 0.000761: 1.2550x faster -Avg: 0.001061 -> 0.000862: 1.2302x faster -Significant (t=6.128572) -Stddev: 0.00052 -> 0.00051: 1.0109x smaller (N = 500) +Min: 0.000882 -> 0.000826: 1.0679x faster +Avg: 0.001003 -> 0.000906: 1.1072x faster +Significant (t=3.338298) +Stddev: 0.00054 -> 0.00036: 1.5250x smaller (N = 500) Running 'query_get' benchmark ... -Min: 0.000268 -> 0.000235: 1.1388x faster -Avg: 0.000293 -> 0.000256: 1.1411x faster -Significant (t=24.002331) -Stddev: 0.00002 -> 0.00003: 1.2917x larger (N = 500) +Min: 0.000280 -> 0.000263: 1.0631x faster +Avg: 0.000303 -> 0.000292: 1.0373x faster +Significant (t=6.991086) +Stddev: 0.00002 -> 0.00002: 1.0173x smaller (N = 500) Running 'query_none' benchmark ... -Min: 0.000055 -> 0.000050: 1.1079x faster -Avg: 0.000061 -> 0.000055: 1.1183x faster -Significant (t=3.149707) -Stddev: 0.00003 -> 0.00004: 1.3162x larger (N = 500) +Min: 0.000052 -> 0.000050: 1.0482x faster +Avg: 0.000058 -> 0.000056: 1.0345x faster +Not significant +Stddev: 0.00003 -> 0.00006: 1.9705x larger (N = 500) Running 'query_complex_filter' benchmark ... -Min: 0.000040 -> 0.000034: 1.1777x faster -Avg: 0.000042 -> 0.000038: 1.1267x faster -Significant (t=15.246074) -Stddev: 0.00000 -> 0.00001: 1.5250x larger (N = 500) +Min: 0.000038 -> 0.000035: 1.0815x faster +Avg: 0.000040 -> 0.000037: 1.0691x faster +Significant (t=10.690955) +Stddev: 0.00000 -> 0.00000: 1.3311x larger (N = 500) Running 'query_filter' benchmark ... -Min: 0.000131 -> 0.000116: 1.1288x faster -Avg: 0.000139 -> 0.000127: 1.0907x faster -Significant (t=14.448319) -Stddev: 0.00001 -> 0.00001: 1.2281x larger (N = 500) +Min: 0.000141 -> 0.000176: 1.2429x slower +Avg: 0.000156 -> 0.000216: 1.3882x slower +Significant (t=-42.392024) +Stddev: 0.00002 -> 0.00003: 1.8049x larger (N = 500) Running 'template_render_simple' benchmark ... -Min: 0.000031 -> 0.000024: 1.2650x faster -Avg: 0.000037 -> 0.000029: 1.2895x faster -Significant (t=2.094800) -Stddev: 0.00007 -> 0.00005: 1.3630x smaller (N = 500) +Min: 0.000030 -> 0.000036: 1.2122x slower +Avg: 0.000035 -> 0.000045: 1.2980x slower +Significant (t=-2.068415) +Stddev: 0.00007 -> 0.00009: 1.3543x larger (N = 500) Running 'default_middleware' benchmark ... -Min: -0.000037 -> -0.000060: 0.6180x faster -Avg: 0.000001 -> 0.000001: 1.0056x slower +Min: -0.000159 -> -0.000214: 0.7434x faster +Avg: 0.000001 -> 0.000001: 1.1672x faster Not significant -Stddev: 0.00002 -> 0.00002: 1.0915x smaller (N = 500) +Stddev: 0.00002 -> 0.00002: 1.1005x larger (N = 500) Running 'query_annotate' benchmark ... -Min: 0.000192 -> 0.000173: 1.1122x faster -Avg: 0.000206 -> 0.000185: 1.1134x faster -Significant (t=17.849733) -Stddev: 0.00002 -> 0.00002: 1.0456x smaller (N = 500) +Min: 0.000204 -> 0.000198: 1.0298x faster +Avg: 0.000226 -> 0.000236: 1.0459x slower +Significant (t=-4.509109) +Stddev: 0.00003 -> 0.00004: 1.5714x larger (N = 500) Running 'raw_sql' benchmark ... -Min: 0.000013 -> 0.000012: 1.0839x faster -Avg: 0.000015 -> 0.000014: 1.0882x faster -Significant (t=4.252084) -Stddev: 0.00001 -> 0.00000: 1.5868x smaller (N = 500) +Min: 0.000018 -> 0.000013: 1.3404x faster +Avg: 0.000019 -> 0.000015: 1.3195x faster +Significant (t=19.789629) +Stddev: 0.00000 -> 0.00000: 1.3561x smaller (N = 500) Running 'url_resolve_flat' benchmark ... -Min: 0.055540 -> 0.046018: 1.2069x faster -Avg: 0.058030 -> 0.048408: 1.1988x faster -Significant (t=98.852976) -Stddev: 0.00157 -> 0.00151: 1.0444x smaller (N = 500) +Min: 0.055935 -> 0.053402: 1.0474x faster +Avg: 0.062895 -> 0.059771: 1.0523x faster +Significant (t=7.194834) +Stddev: 0.00723 -> 0.00648: 1.1147x smaller (N = 500) Running 'l10n_render' benchmark ... -Min: 0.001604 -> 0.001253: 1.2797x faster -Avg: 0.001684 -> 0.001304: 1.2918x faster -Significant (t=37.535402) -Stddev: 0.00017 -> 0.00015: 1.1476x smaller (N = 500) +Min: 0.001529 -> 0.001251: 1.2219x faster +Avg: 0.001611 -> 0.001377: 1.1701x faster +Significant (t=18.793991) +Stddev: 0.00018 -> 0.00021: 1.1812x larger (N = 500) Running 'query_count' benchmark ... -Min: 0.000176 -> 0.000165: 1.0631x faster -Avg: 0.000189 -> 0.000176: 1.0755x faster -Significant (t=12.229046) -Stddev: 0.00002 -> 0.00002: 1.0395x larger (N = 500) +Min: 0.000205 -> 0.000190: 1.0786x faster +Avg: 0.000230 -> 0.000223: 1.0340x faster +Significant (t=3.666845) +Stddev: 0.00003 -> 0.00004: 1.3467x larger (N = 500) Running 'model_delete' benchmark ... -Min: 0.000122 -> 0.000104: 1.1743x faster -Avg: 0.000152 -> 0.000115: 1.3227x faster -Significant (t=19.812953) -Stddev: 0.00004 -> 0.00001: 2.6554x smaller (N = 500) +Min: 0.000125 -> 0.000115: 1.0868x faster +Avg: 0.000146 -> 0.000135: 1.0808x faster +Significant (t=7.537652) +Stddev: 0.00003 -> 0.00002: 1.4769x smaller (N = 500) Running 'query_iterator' benchmark ... -Min: 0.000108 -> 0.000094: 1.1518x faster -Avg: 0.000119 -> 0.000098: 1.2203x faster -Significant (t=21.984884) -Stddev: 0.00002 -> 0.00001: 2.7750x smaller (N = 500) +Min: 0.000110 -> 0.000097: 1.1344x faster +Avg: 0.000116 -> 0.000103: 1.1269x faster +Significant (t=19.477018) +Stddev: 0.00001 -> 0.00001: 1.0328x larger (N = 500) Running 'template_compilation' benchmark ... -Min: 0.000164 -> 0.000148: 1.1034x faster -Avg: 0.000184 -> 0.000162: 1.1386x faster -Significant (t=4.665298) -Stddev: 0.00008 -> 0.00007: 1.2952x smaller (N = 500) +Min: 0.000157 -> 0.000157: 1.0038x faster +Avg: 0.000173 -> 0.000169: 1.0255x faster +Not significant +Stddev: 0.00008 -> 0.00008: 1.0180x smaller (N = 500) Running 'query_all_multifield' benchmark ... -Min: 0.014802 -> 0.012188: 1.2144x faster -Avg: 0.016029 -> 0.013294: 1.2057x faster -Significant (t=21.516971) -Stddev: 0.00210 -> 0.00191: 1.0984x smaller (N = 500) +Min: 0.014928 -> 0.014535: 1.0270x faster +Avg: 0.017357 -> 0.016710: 1.0387x faster +Significant (t=3.854898) +Stddev: 0.00263 -> 0.00268: 1.0198x larger (N = 500) Running 'query_prefetch_related' benchmark ... -Min: 0.013401 -> 0.011583: 1.1569x faster -Avg: 0.014822 -> 0.013366: 1.1090x faster -Significant (t=11.422100) -Stddev: 0.00170 -> 0.00229: 1.3410x larger (N = 500) +Min: 0.014613 -> 0.013929: 1.0491x faster +Avg: 0.016610 -> 0.016188: 1.0261x faster +Significant (t=2.746974) +Stddev: 0.00236 -> 0.00250: 1.0569x larger (N = 500) Running 'query_all_converters' benchmark ... -Min: 0.000499 -> 0.000429: 1.1618x faster -Avg: 0.000531 -> 0.000455: 1.1670x faster -Significant (t=42.716720) -Stddev: 0.00002 -> 0.00003: 1.5394x larger (N = 500) +Min: 0.000525 -> 0.000493: 1.0659x faster +Avg: 0.000604 -> 0.000527: 1.1458x faster +Significant (t=24.506675) +Stddev: 0.00006 -> 0.00004: 1.7192x smaller (N = 500) Running 'query_distinct' benchmark ... -Min: 0.000108 -> 0.000095: 1.1397x faster -Avg: 0.000116 -> 0.000100: 1.1646x faster -Significant (t=25.915629) -Stddev: 0.00001 -> 0.00001: 1.1204x larger (N = 500) +Min: 0.000150 -> 0.000181: 1.2049x slower +Avg: 0.000159 -> 0.000231: 1.4503x slower +Significant (t=-31.080159) +Stddev: 0.00002 -> 0.00005: 3.0049x larger (N = 500) Running 'query_dates' benchmark ... -Min: 0.000333 -> 0.000290: 1.1490x faster -Avg: 0.000365 -> 0.000326: 1.1207x faster -Significant (t=18.213858) -Stddev: 0.00003 -> 0.00003: 1.0118x larger (N = 500) +Min: 0.000512 -> 0.000402: 1.2740x faster +Avg: 0.000677 -> 0.000541: 1.2510x faster +Significant (t=18.130874) +Stddev: 0.00014 -> 0.00009: 1.5731x smaller (N = 500) Running 'model_save_existing' benchmark ... -Min: 0.003455 -> 0.003081: 1.1215x faster -Avg: 0.003764 -> 0.003326: 1.1316x faster -Significant (t=32.229651) -Stddev: 0.00023 -> 0.00020: 1.1398x smaller (N = 500) +Min: 0.004219 -> 0.003506: 1.2033x faster +Avg: 0.005591 -> 0.004282: 1.3058x faster +Significant (t=24.601648) +Stddev: 0.00105 -> 0.00056: 1.8802x smaller (N = 500) Running 'query_delete_related' benchmark ... -Min: 0.000122 -> 0.000102: 1.1946x faster -Avg: 0.000131 -> 0.000113: 1.1564x faster -Significant (t=5.027485) -Stddev: 0.00005 -> 0.00006: 1.4129x larger (N = 500) +Min: 0.000146 -> 0.000113: 1.2893x faster +Avg: 0.000164 -> 0.000125: 1.3116x faster +Significant (t=11.903195) +Stddev: 0.00006 -> 0.00004: 1.2887x smaller (N = 500) Running 'url_reverse' benchmark ... -Min: 0.000068 -> 0.000067: 1.0193x faster -Avg: 0.000075 -> 0.000074: 1.0157x faster -Not significant -Stddev: 0.00006 -> 0.00005: 1.1543x smaller (N = 500) +Min: 0.000083 -> 0.000051: 1.6336x faster +Avg: 0.000098 -> 0.000057: 1.7123x faster +Significant (t=9.922770) +Stddev: 0.00008 -> 0.00005: 1.5293x smaller (N = 500) Running 'query_latest' benchmark ... -Min: 0.000147 -> 0.000138: 1.0631x faster -Avg: 0.000167 -> 0.000148: 1.1277x faster -Significant (t=11.353029) -Stddev: 0.00003 -> 0.00002: 1.6091x smaller (N = 500) +Min: 0.000171 -> 0.000149: 1.1500x faster +Avg: 0.000191 -> 0.000167: 1.1440x faster +Significant (t=9.636091) +Stddev: 0.00005 -> 0.00003: 1.6181x smaller (N = 500) Running 'form_create' benchmark ... -Min: 0.000016 -> 0.000013: 1.2659x faster -Avg: 0.000020 -> 0.000015: 1.2770x faster -Significant (t=3.482649) -Stddev: 0.00002 -> 0.00002: 1.0947x larger (N = 500) +Min: 0.000015 -> 0.000015: 1.0149x slower +Avg: 0.000018 -> 0.000018: 1.0134x faster +Not significant +Stddev: 0.00002 -> 0.00002: 1.0031x smaller (N = 500) Running 'query_update' benchmark ... -Min: 0.000047 -> 0.000043: 1.0971x faster -Avg: 0.000050 -> 0.000046: 1.0691x faster -Significant (t=9.363513) -Stddev: 0.00001 -> 0.00000: 1.2636x smaller (N = 500) +Min: 0.000048 -> 0.000045: 1.0663x faster +Avg: 0.000052 -> 0.000048: 1.0711x faster +Significant (t=7.190354) +Stddev: 0.00001 -> 0.00001: 1.3463x larger (N = 500) Running 'query_in_bulk' benchmark ... -Min: 0.000157 -> 0.000143: 1.0970x faster -Avg: 0.000178 -> 0.000162: 1.0981x faster -Significant (t=9.031182) -Stddev: 0.00002 -> 0.00003: 1.5173x larger (N = 500) +Min: 0.000161 -> 0.000198: 1.2326x slower +Avg: 0.000176 -> 0.000269: 1.5247x slower +Significant (t=-26.624807) +Stddev: 0.00003 -> 0.00007: 2.2105x larger (N = 500) Running 'url_resolve_nested' benchmark ... -Min: 0.000046 -> 0.000038: 1.2179x faster -Avg: 0.000075 -> 0.000052: 1.4505x faster +Min: 0.000063 -> 0.000042: 1.4993x faster +Avg: 0.000082 -> 0.000061: 1.3509x faster Not significant -Stddev: 0.00059 -> 0.00024: 2.4300x smaller (N = 500) +Stddev: 0.00027 -> 0.00033: 1.2034x larger (N = 500) Running 'model_creation' benchmark ... -Min: 0.000071 -> 0.000065: 1.1058x faster -Avg: 0.000079 -> 0.000073: 1.0876x faster -Significant (t=2.786580) -Stddev: 0.00003 -> 0.00004: 1.1518x larger (N = 500) +Min: 0.000079 -> 0.000074: 1.0644x faster +Avg: 0.000089 -> 0.000087: 1.0230x faster +Not significant +Stddev: 0.00005 -> 0.00008: 1.4667x larger (N = 500) Running 'query_order_by' benchmark ... -Min: 0.000146 -> 0.000128: 1.1407x faster -Avg: 0.000154 -> 0.000138: 1.1206x faster -Significant (t=14.021341) -Stddev: 0.00002 -> 0.00002: 1.2540x larger (N = 500) +Min: 0.000179 -> 0.000162: 1.1071x faster +Avg: 0.000207 -> 0.000183: 1.1311x faster +Significant (t=9.116430) +Stddev: 0.00005 -> 0.00003: 1.6620x smaller (N = 500) Running 'startup' benchmark ... Skipped: Django 1.9 and later has changed app loading. This benchmark needs fixing anyway. Running 'form_clean' benchmark ... -Min: 0.000005 -> 0.000004: 1.4613x faster -Avg: 0.000006 -> 0.000004: 1.3654x faster -Significant (t=12.763128) -Stddev: 0.00000 -> 0.00000: 1.1666x larger (N = 500) +Min: 0.000005 -> 0.000004: 1.1374x faster +Avg: 0.000005 -> 0.000005: 1.1159x faster +Significant (t=3.486468) +Stddev: 0.00000 -> 0.00000: 1.1186x smaller (N = 500) Running 'locale_from_request' benchmark ... -Min: 0.000097 -> 0.000108: 1.1090x slower -Avg: 0.000108 -> 0.000120: 1.1178x slower -Significant (t=-3.057677) -Stddev: 0.00007 -> 0.00006: 1.1186x smaller (N = 500) +Min: 0.000126 -> 0.000117: 1.0788x faster +Avg: 0.000141 -> 0.000130: 1.0820x faster +Significant (t=2.168131) +Stddev: 0.00008 -> 0.00008: 1.0548x larger (N = 500) Running 'query_exists' benchmark ... -Min: 0.000273 -> 0.000234: 1.1698x faster -Avg: 0.000290 -> 0.000248: 1.1686x faster -Significant (t=39.518859) -Stddev: 0.00002 -> 0.00002: 1.2025x smaller (N = 500) +Min: 0.000339 -> 0.000270: 1.2522x faster +Avg: 0.000390 -> 0.000302: 1.2915x faster +Significant (t=32.599092) +Stddev: 0.00005 -> 0.00003: 1.6766x smaller (N = 500) Running 'query_values_10000' benchmark ... -Min: 0.005601 -> 0.005298: 1.0571x faster -Avg: 0.006023 -> 0.005691: 1.0583x faster -Significant (t=6.167352) -Stddev: 0.00082 -> 0.00088: 1.0752x larger (N = 500) +Min: 0.007119 -> 0.005268: 1.3513x faster +Avg: 0.007891 -> 0.006276: 1.2573x faster +Significant (t=18.731021) +Stddev: 0.00120 -> 0.00151: 1.2516x larger (N = 500) Running 'query_exclude' benchmark ... -Min: 0.000159 -> 0.000140: 1.1367x faster -Avg: 0.000165 -> 0.000149: 1.1020x faster -Significant (t=19.643154) -Stddev: 0.00001 -> 0.00001: 1.2636x larger (N = 500) +Min: 0.000181 -> 0.000157: 1.1532x faster +Avg: 0.000222 -> 0.000173: 1.2822x faster +Significant (t=22.161234) +Stddev: 0.00005 -> 0.00002: 2.4379x smaller (N = 500) Running 'query_raw' benchmark ... -Min: 0.005764 -> 0.004630: 1.2450x faster -Avg: 0.006169 -> 0.004881: 1.2638x faster -Significant (t=20.996453) -Stddev: 0.00109 -> 0.00083: 1.3105x smaller (N = 500) +Min: 0.006000 -> 0.005498: 1.0913x faster +Avg: 0.006669 -> 0.006219: 1.0723x faster +Significant (t=5.713937) +Stddev: 0.00118 -> 0.00130: 1.0984x larger (N = 500) Running 'url_resolve' benchmark ... -Min: 0.004928 -> 0.004597: 1.0721x faster -Avg: 0.005217 -> 0.004716: 1.1063x faster -Significant (t=46.893945) -Stddev: 0.00022 -> 0.00010: 2.2192x smaller (N = 500) +Min: 0.005204 -> 0.004399: 1.1832x faster +Avg: 0.005764 -> 0.004764: 1.2099x faster +Significant (t=38.897887) +Stddev: 0.00055 -> 0.00018: 3.0723x smaller (N = 500) Running 'model_save_new' benchmark ... -Min: 0.003404 -> 0.003012: 1.1301x faster -Avg: 0.003494 -> 0.003105: 1.1251x faster -Significant (t=45.888484) -Stddev: 0.00014 -> 0.00013: 1.0298x smaller (N = 500) +Min: 0.003674 -> 0.003351: 1.0967x faster +Avg: 0.003917 -> 0.003604: 1.0868x faster +Significant (t=21.508370) +Stddev: 0.00021 -> 0.00025: 1.2091x larger (N = 500) Running 'query_all' benchmark ... -Min: 0.007971 -> 0.007085: 1.1250x faster -Avg: 0.009091 -> 0.008147: 1.1159x faster -Significant (t=7.583074) -Stddev: 0.00183 -> 0.00210: 1.1518x larger (N = 500) +Min: 0.008655 -> 0.008097: 1.0689x faster +Avg: 0.010801 -> 0.009255: 1.1669x faster +Significant (t=8.961354) +Stddev: 0.00304 -> 0.00237: 1.2846x smaller (N = 500) +``` + +### Python 3.12.3 Dj4.2 vs Dj5.0 + +This benchmark is purely for development notes. + +- Djangobench 0.10.0 +- Python 3.12.3 +- Django 4.2.13 vs Django 5.0.6 + +```bash +python3.8 -m venv py38 +python3.11 -m venv py38 +pip install -e git://github.com/django/djangobench.git#egg=djangobench +git clone https://github.com/django/django.git +cd django + +ozira@METABOX:~/djangobench/django$ djangobench --control=4.2.13 --experiment=5.0.6 --control-python=/home/ozira/djangobench/py312/bin/python --experiment-python=/home/ozira/djangobench/py312/bin/python -r /home/ozira/djangobench/results -t 500 +Running all benchmarks +Recording data to '/home/ozira/djangobench/results' +Control: Django 4.2.13 (in git branch 4.2.13) +Experiment: Django 5.0.6 (in git branch 5.0.6) + +Running 'multi_value_dict' benchmark ... +Min: 0.000013 -> 0.000023: 1.7898x slower +Avg: 0.000159 -> 0.000314: 1.9720x slower +Significant (t=-18.448864) +Stddev: 0.00009 -> 0.00017: 1.8462x larger (N = 500) + +Running 'query_values' benchmark ... +Min: 0.000086 -> 0.000093: 1.0836x slower +Avg: 0.000092 -> 0.000101: 1.1016x slower +Significant (t=-13.223024) +Stddev: 0.00001 -> 0.00001: 1.2472x larger (N = 500) + +Running 'query_delete' benchmark ... +Min: 0.000098 -> 0.000085: 1.1525x faster +Avg: 0.000109 -> 0.000105: 1.0412x faster +Significant (t=3.610998) +Stddev: 0.00002 -> 0.00002: 1.2485x larger (N = 500) + +Running 'query_select_related' benchmark ... +Min: 0.016080 -> 0.017390: 1.0815x slower +Avg: 0.018038 -> 0.020007: 1.1092x slower +Significant (t=-10.013539) +Stddev: 0.00204 -> 0.00390: 1.9094x larger (N = 500) + +Running 'query_aggregate' benchmark ... +Min: 0.000195 -> 0.000186: 1.0503x faster +Avg: 0.000225 -> 0.000210: 1.0729x faster +Significant (t=6.534745) +Stddev: 0.00004 -> 0.00004: 1.0807x smaller (N = 500) + +Running 'query_raw_deferred' benchmark ... +Min: 0.003904 -> 0.004196: 1.0748x slower +Avg: 0.004346 -> 0.004650: 1.0698x slower +Significant (t=-4.131647) +Stddev: 0.00113 -> 0.00119: 1.0537x larger (N = 500) + +Running 'query_get_or_create' benchmark ... +Min: 0.000447 -> 0.000482: 1.0795x slower +Avg: 0.000546 -> 0.000559: 1.0244x slower +Not significant +Stddev: 0.00012 -> 0.00010: 1.1415x smaller (N = 500) + +Running 'query_values_list' benchmark ... +Min: 0.000082 -> 0.000085: 1.0385x slower +Avg: 0.000089 -> 0.000093: 1.0418x slower +Significant (t=-4.441191) +Stddev: 0.00001 -> 0.00002: 1.5940x larger (N = 500) + +Running 'url_resolve_flat_i18n_off' benchmark ... +Min: 0.054035 -> 0.054465: 1.0079x slower +Avg: 0.062802 -> 0.058801: 1.0680x faster +Significant (t=4.849003) +Stddev: 0.01815 -> 0.00330: 5.4996x smaller (N = 500) + +Running 'qs_filter_chaining' benchmark ... +Min: 0.000242 -> 0.000301: 1.2454x slower +Avg: 0.000255 -> 0.000320: 1.2553x slower +Significant (t=-19.514075) +Stddev: 0.00004 -> 0.00006: 1.3907x larger (N = 500) + +Running 'template_render' benchmark ... +Min: 0.000849 -> 0.000823: 1.0308x faster +Avg: 0.000985 -> 0.000914: 1.0773x faster +Significant (t=2.995514) +Stddev: 0.00036 -> 0.00038: 1.0474x larger (N = 500) + +Running 'query_get' benchmark ... +Min: 0.000283 -> 0.000272: 1.0390x faster +Avg: 0.000325 -> 0.000304: 1.0704x faster +Significant (t=10.235216) +Stddev: 0.00004 -> 0.00003: 1.3055x smaller (N = 500) + +Running 'query_none' benchmark ... +Min: 0.000069 -> 0.000093: 1.3482x slower +Avg: 0.000081 -> 0.000103: 1.2714x slower +Significant (t=-3.771605) +Stddev: 0.00011 -> 0.00008: 1.3869x smaller (N = 500) + +Running 'query_complex_filter' benchmark ... +Min: 0.000048 -> 0.000039: 1.2131x faster +Avg: 0.000051 -> 0.000042: 1.2180x faster +Significant (t=23.139363) +Stddev: 0.00001 -> 0.00001: 1.1332x smaller (N = 500) + +Running 'query_filter' benchmark ... +Min: 0.000143 -> 0.000195: 1.3597x slower +Avg: 0.000162 -> 0.000218: 1.3425x slower +Significant (t=-15.508875) +Stddev: 0.00007 -> 0.00003: 2.6056x smaller (N = 500) + +Running 'template_render_simple' benchmark ... +Min: 0.000042 -> 0.000029: 1.4210x faster +Avg: 0.000052 -> 0.000036: 1.4621x faster +Significant (t=2.949575) +Stddev: 0.00010 -> 0.00007: 1.3581x smaller (N = 500) + +Running 'default_middleware' benchmark ... +Min: -0.000154 -> -0.000074: 0.4827x slower +Avg: 0.000002 -> 0.000002: 1.5375x slower +Not significant +Stddev: 0.00003 -> 0.00003: 1.0173x smaller (N = 500) + +Running 'query_annotate' benchmark ... +Min: 0.000200 -> 0.000204: 1.0182x slower +Avg: 0.000230 -> 0.000245: 1.0629x slower +Significant (t=-7.240006) +Stddev: 0.00003 -> 0.00003: 1.0010x larger (N = 500) + +Running 'raw_sql' benchmark ... +Min: 0.000013 -> 0.000015: 1.1728x slower +Avg: 0.000014 -> 0.000016: 1.1890x slower +Significant (t=-9.630569) +Stddev: 0.00000 -> 0.00000: 1.3213x larger (N = 500) + +Running 'url_resolve_flat' benchmark ... +Min: 0.054495 -> 0.053987: 1.0094x faster +Avg: 0.059588 -> 0.059220: 1.0062x faster +Not significant +Stddev: 0.00520 -> 0.00563: 1.0816x larger (N = 500) + +Running 'l10n_render' benchmark ... +Min: 0.001263 -> 0.000914: 1.3821x faster +Avg: 0.001386 -> 0.001024: 1.3533x faster +Significant (t=29.074072) +Stddev: 0.00020 -> 0.00020: 1.0040x smaller (N = 500) + +Running 'query_count' benchmark ... +Min: 0.000178 -> 0.000186: 1.0407x slower +Avg: 0.000196 -> 0.000203: 1.0335x slower +Significant (t=-2.855455) +Stddev: 0.00005 -> 0.00002: 1.9799x smaller (N = 500) + +Running 'model_delete' benchmark ... +Min: 0.000124 -> 0.000109: 1.1351x faster +Avg: 0.000144 -> 0.000125: 1.1548x faster +Significant (t=15.819525) +Stddev: 0.00002 -> 0.00002: 1.3262x smaller (N = 500) + +Running 'query_iterator' benchmark ... +Min: 0.000099 -> 0.000117: 1.1885x slower +Avg: 0.000104 -> 0.000126: 1.2099x slower +Significant (t=-28.698598) +Stddev: 0.00001 -> 0.00001: 1.3498x larger (N = 500) + +Running 'template_compilation' benchmark ... +Min: 0.000150 -> 0.000153: 1.0177x slower +Avg: 0.000162 -> 0.000165: 1.0142x slower +Not significant +Stddev: 0.00009 -> 0.00008: 1.0964x smaller (N = 500) + +Running 'query_all_multifield' benchmark ... +Min: 0.015027 -> 0.015956: 1.0618x slower +Avg: 0.016603 -> 0.017869: 1.0763x slower +Significant (t=-7.678978) +Stddev: 0.00252 -> 0.00269: 1.0650x larger (N = 500) + +Running 'query_prefetch_related' benchmark ... +Min: 0.014046 -> 0.013922: 1.0089x faster +Avg: 0.015939 -> 0.016489: 1.0346x slower +Significant (t=-3.883798) +Stddev: 0.00227 -> 0.00221: 1.0253x smaller (N = 500) + +Running 'query_all_converters' benchmark ... +Min: 0.000544 -> 0.000523: 1.0396x faster +Avg: 0.000598 -> 0.000560: 1.0685x faster +Significant (t=16.329893) +Stddev: 0.00004 -> 0.00004: 1.0470x larger (N = 500) + +Running 'query_distinct' benchmark ... +Min: 0.000103 -> 0.000109: 1.0592x slower +Avg: 0.000112 -> 0.000116: 1.0375x slower +Significant (t=-5.586589) +Stddev: 0.00001 -> 0.00001: 1.0100x smaller (N = 500) + +Running 'query_dates' benchmark ... +Min: 0.000356 -> 0.000405: 1.1369x slower +Avg: 0.000403 -> 0.000460: 1.1406x slower +Significant (t=-19.572384) +Stddev: 0.00004 -> 0.00005: 1.1089x larger (N = 500) + +Running 'model_save_existing' benchmark ... +Min: 0.003422 -> 0.003479: 1.0166x slower +Avg: 0.003788 -> 0.003807: 1.0049x slower +Not significant +Stddev: 0.00021 -> 0.00017: 1.2258x smaller (N = 500) + +Running 'query_delete_related' benchmark ... +Min: 0.000114 -> 0.000113: 1.0052x faster +Avg: 0.000127 -> 0.000130: 1.0189x slower +Not significant +Stddev: 0.00005 -> 0.00005: 1.0220x smaller (N = 500) + +Running 'url_reverse' benchmark ... +Min: 0.000048 -> 0.000050: 1.0329x slower +Avg: 0.000055 -> 0.000063: 1.1449x slower +Significant (t=-2.155616) +Stddev: 0.00005 -> 0.00007: 1.3065x larger (N = 500) + +Running 'query_latest' benchmark ... +Min: 0.000139 -> 0.000143: 1.0305x slower +Avg: 0.000153 -> 0.000157: 1.0231x slower +Significant (t=-2.436627) +Stddev: 0.00002 -> 0.00002: 1.1560x larger (N = 500) + +Running 'form_create' benchmark ... +Min: 0.000014 -> 0.000013: 1.0312x faster +Avg: 0.000016 -> 0.000015: 1.0981x faster +Not significant +Stddev: 0.00002 -> 0.00002: 1.1374x larger (N = 500) + +Running 'query_update' benchmark ... +Min: 0.000044 -> 0.000045: 1.0237x slower +Avg: 0.000047 -> 0.000049: 1.0507x slower +Significant (t=-5.285934) +Stddev: 0.00001 -> 0.00001: 1.7229x larger (N = 500) + +Running 'query_in_bulk' benchmark ... +Min: 0.000164 -> 0.000147: 1.1136x faster +Avg: 0.000191 -> 0.000166: 1.1519x faster +Significant (t=17.531877) +Stddev: 0.00003 -> 0.00002: 1.4907x smaller (N = 500) + +Running 'url_resolve_nested' benchmark ... +Min: 0.000047 -> 0.000039: 1.2059x faster +Avg: 0.000066 -> 0.000053: 1.2379x faster +Not significant +Stddev: 0.00035 -> 0.00027: 1.3017x smaller (N = 500) + +Running 'model_creation' benchmark ... +Min: 0.000071 -> 0.000075: 1.0607x slower +Avg: 0.000080 -> 0.000085: 1.0648x slower +Not significant +Stddev: 0.00007 -> 0.00004: 1.6986x smaller (N = 500) + +Running 'query_order_by' benchmark ... +Min: 0.000144 -> 0.000159: 1.1010x slower +Avg: 0.000160 -> 0.000176: 1.1021x slower +Significant (t=-8.959905) +Stddev: 0.00003 -> 0.00003: 1.0795x larger (N = 500) + +Running 'startup' benchmark ... +Skipped: Django 1.9 and later has changed app loading. This benchmark needs fixing anyway. + +Running 'form_clean' benchmark ... +Min: 0.000004 -> 0.000004: 1.0084x slower +Avg: 0.000004 -> 0.000004: 1.0378x faster +Not significant +Stddev: 0.00000 -> 0.00000: 1.6388x smaller (N = 500) + +Running 'locale_from_request' benchmark ... +Min: 0.000112 -> 0.000107: 1.0460x faster +Avg: 0.000119 -> 0.000115: 1.0323x faster +Not significant +Stddev: 0.00007 -> 0.00006: 1.0659x smaller (N = 500) + +Running 'query_exists' benchmark ... +Min: 0.000281 -> 0.000273: 1.0274x faster +Avg: 0.000327 -> 0.000304: 1.0761x faster +Significant (t=8.912446) +Stddev: 0.00005 -> 0.00003: 1.4371x smaller (N = 500) + +Running 'query_values_10000' benchmark ... +Min: 0.005139 -> 0.005398: 1.0505x slower +Avg: 0.005799 -> 0.005876: 1.0133x slower +Not significant +Stddev: 0.00117 -> 0.00113: 1.0364x smaller (N = 500) + +Running 'query_exclude' benchmark ... +Min: 0.000161 -> 0.000160: 1.0074x faster +Avg: 0.000177 -> 0.000174: 1.0209x faster +Significant (t=3.498767) +Stddev: 0.00002 -> 0.00002: 1.0594x smaller (N = 500) + +Running 'query_raw' benchmark ... +Min: 0.005483 -> 0.005660: 1.0323x slower +Avg: 0.006040 -> 0.006549: 1.0843x slower +Significant (t=-6.551792) +Stddev: 0.00110 -> 0.00134: 1.2183x larger (N = 500) + +Running 'url_resolve' benchmark ... +Min: 0.004650 -> 0.004575: 1.0164x faster +Avg: 0.005069 -> 0.004889: 1.0370x faster +Significant (t=7.516165) +Stddev: 0.00044 -> 0.00030: 1.4556x smaller (N = 500) + +Running 'model_save_new' benchmark ... +Min: 0.003318 -> 0.003369: 1.0154x slower +Avg: 0.003624 -> 0.003783: 1.0437x slower +Significant (t=-9.047954) +Stddev: 0.00026 -> 0.00029: 1.1087x larger (N = 500) + +Running 'query_all' benchmark ... +Min: 0.007900 -> 0.008847: 1.1198x slower +Avg: 0.008945 -> 0.010023: 1.1206x slower +Significant (t=-7.386401) +Stddev: 0.00224 -> 0.00237: 1.0590x larger (N = 500) ``` diff --git a/docs/maintenance/tuning/web.md b/docs/maintenance/tuning/web.md new file mode 100644 index 00000000..b4241bbf --- /dev/null +++ b/docs/maintenance/tuning/web.md @@ -0,0 +1,156 @@ +# Web Tuning + +## Gunicorn + +### Number of workers + +The default installation will have 3 workers configured for Gunicorn. This will be fine on most systems, but if your system as more than one core than you might want to increase the number of workers to get better response times. Note that more workers will also need more RAM though. + +The number you set this to will depend on your own server environment, how many visitors you have etc. Gunicorn suggests `(2 x $num_cores) + 1` for the number of workers. So for example, if you have 2 cores, you want 2 x 2 + 1 = 5 workers. See [here](https://docs.gunicorn.org/en/stable/design.html#how-many-workers) for the official discussion on this topic. + +::::{tabs} +:::{group-tab} Ubuntu 2204, 2404 +To have 5 workers change the setting `--workers=x` to `--workers=5` in your `supervisor.conf` file and then reload the supervisor with the following command to activate the change + +```shell +systemctl restart supervisor +``` + +::: +:::{group-tab} CentOS / RHEL +To have 5 workers change the setting `--workers=x` to `--workers=5` in your `supervisor.conf` file and then reload the supervisor with the following command to activate the change + +```shell +systemctl restart supervisor +``` + +::: +:::{group-tab} Docker Compose +To have 5 workers change the setting `--workers=3` to `--workers=5` in your `docker-compose.yml` file and then restart the container as follows + +```shell +docker compose up -d +``` + +::: +:::: + +## nginx + +### nginx repo + +We can use the Nginx repositories for a slightly more cutting edge version of Nginx, with more features. Install it to enable the below features + +::::{tabs} +:::{group-tab} Ubuntu 2204, 2404 + +::: +:::{group-tab} CentOS / RHEL + +::: +:::{group-tab} Docker +No package necessary, simply increase `docker compose pull` and `docker compose up -d` to update. +::: +:::: + +### Brotli Compression + +Brotli is a modern compression algorithm designed for the web. Use this with Pre-Compression and E2E Cloudflare compression for best results. + +::::{tabs} +:::{group-tab} Ubuntu 2204, 2404 +sudo apt update +sudo apt install libnginx-mod-http-brotli-filter libnginx-mod-http-brotli-static +::: +:::{group-tab} CentOS +WIP +::: +:::{group-tab} Docker +Pull a custom dockerfile + +```bash +mkdir nginx +curl -o my-nginx/Dockerfile https://raw.githubusercontent.com/nginxinc/docker-nginx/master/modules/Dockerfile +``` + +Replace the nginx service in your docker-compose as follows + +```dockerfile + nginx: + build: + context: ./nginx/ + args: + ENABLED_MODULES: brotli + restart: always + volumes: + - ./conf/nginx.conf:/etc/nginx/nginx.conf + - static-volume:/var/www/myauth/static + depends_on: + - allianceauth_gunicorn + logging: + driver: "json-file" + options: + max-size: "10Mb" + max-file: "5" +``` + +::: +:::: + +Modify your nginx.conf as follows + +```conf +load_module modules/ngx_http_brotli_static_module.so; +load_module modules/ngx_http_brotli_filter_module.so; +... +http { + ... + server { + ... + location /static { + ... + brotli_static on; + brotli_types application/javascript text/css font/woff2 image/png image/svg+xml font/woff image/gif; + brotli_comp_level 11; + } + ... + location / { + ... + brotli on; + brotli_comp_level 4; + } + } +} +``` + +### Staticfile Pre-Compression + +We can use a small library to pre-compress staticfiles for Nginx to deliver. + +```shell +pip install django-static-compress +``` + +Add the following lines to local.py + +```python +# Tuning / Compression +STORAGES = { + "staticfiles": { + "BACKEND": "static_compress.CompressedStaticFilesStorage", + }, +} + +STATIC_COMPRESS_FILE_EXTS = ['js', 'css', 'woff2', 'png', 'svg', 'woff', 'gif'] +STATIC_COMPRESS_METHODS = ['gz', 'br'] +STATIC_COMPRESS_KEEP_ORIGINAL = True +STATIC_COMPRESS_MIN_SIZE_KB = 1 +``` + +## Cloudflare + +### Brotli E2E Compression + +Soon to be turned on by default. Refer to + +In order for cloudflare to seamlessly pass on your brotli compressed pages (End to End), ensure minification, rocket loader and other features are _off_ . Else cloudflare will need to uncompress, modify, then recompress your pages.