-
Notifications
You must be signed in to change notification settings - Fork 926
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bedrock performance tooling and initial optimisations (#15513)
* Add support for Django-silk profiling in local/non-prod only Also add script to hit some common/popular URLs to give djanjo-silk some traffic to capture * Add cacheing to geo.valid_country_code for performance boost Saves 11 SQL queries on the releasnotes page by cacheing the country code lookup for an hour. Tested on /en-US/firefox/132.0.1/releasenotes/ Cold cache: 14 queries / 2066ms Warm cache: 3 queries / 222ms * Rename 'default' cache time to CACHE_TIME_SHORT to make it more meaningful a name * Add cacheing to Careers views to reduce number of DB hits Caches derived values (location options, etc) for longer than the actual page of positions Takes careers listing page down from 9 queries to 2 for the CMS deployment and 0 on the Web deployment * Cache the newsletter lookup for 6 hours It's used on the newsletter form which shows up in a bunch of places on the site. * Add missing subdep to hashed requirements * Reinstate missing function call in _log() helper 🤦
- Loading branch information
1 parent
9db97b8
commit 25b38f7
Showing
12 changed files
with
211 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
"""Request a selection of pages that are populat on www.m.o from your local | ||
runserver, so that django-silk can capture performance info on them. | ||
Usage: | ||
1. In your .env set ENABLE_DJANGO_SILK=True | ||
2. Start your runserver on port 8000 | ||
3. python profiling/hit_popular_pages.py | ||
3. View results at http://localhost:8000/silk/ | ||
""" | ||
|
||
import sys | ||
import time | ||
|
||
import requests | ||
|
||
paths = [ | ||
"/en-US/firefox/126.0/whatsnew/", | ||
"/en-US/firefox/", | ||
"/en-US/firefox/windows/", | ||
"/en-US/firefox/new/?reason=manual-update", | ||
"/en-US/firefox/download/thanks/", | ||
"/en-US/firefox/new/?reason=outdated", | ||
"/en-US/firefox/features/", | ||
"/en-US/firefox/all/", | ||
"/en-US/firefox/welcome/18/", | ||
"/en-US/", | ||
"/en-US/firefox/installer-help/?channel=release&installer_lang=en-US", | ||
"/en-US/firefox/download/thanks/?s=direct", | ||
"/en-US/firefox/welcome/19/", | ||
"/en-US/firefox/enterprise/?reason=manual-update", | ||
"/en-US/products/vpn/", | ||
"/en-US/firefox/browsers/windows-64-bit/", | ||
"/en-US/firefox/mac/", | ||
"/en-US/about/", | ||
"/en-US/firefox/android/124.0/releasenotes/", | ||
"/en-US/firefox/browsers/mobile/get-app/", | ||
"/en-US/firefox/browsers/", | ||
"/en-US/firefox/nightly/firstrun/", | ||
"/en-US/firefox/developer/", | ||
"/en-US/account/", | ||
"/en-US/contribute/", | ||
"/en-US/firefox/browsers/mobile/android/", | ||
"/en-US/privacy/archive/firefox-fire-tv/2023-06/", | ||
"/en-US/firefox/121.0/system-requirements/", | ||
"/en-US/firefox/browsers/mobile/", | ||
"/en-US/firefox/releases/", | ||
"/en-US/MPL/", | ||
"/en-US/firefox/enterprise/", | ||
"/en-US/security/advisories/", | ||
"/en-US/firefox/browsers/what-is-a-browser/", | ||
"/en-US/firefox/channel/desktop/?reason=manual-update", | ||
"/en-US/firefox/pocket/", | ||
"/en-US/firefox/channel/desktop/", | ||
"/en-US/firefox/welcome/17b/", | ||
"/en-US/firefox/welcome/17c/", | ||
"/en-US/firefox/welcome/17a/", | ||
"/en-US/firefox/set-as-default/thanks/", | ||
"/en-US/careers/listings/", | ||
"/en-US/firefox/browsers/chromebook/", | ||
"/en-US/firefox/nothing-personal/", | ||
"/en-US/newsletter/existing/", | ||
"/en-US/about/legal/terms/firefox/", | ||
"/en-US/firefox/linux/", | ||
"/en-US/firefox/browsers/mobile/focus/", | ||
"/en-US/products/vpn/download/", | ||
"/en-US/about/manifesto/", | ||
"/en-US/stories/joy-of-color/", | ||
"/en-US/contact/", | ||
"/en-US/about/legal/defend-mozilla-trademarks/", | ||
] | ||
|
||
|
||
def _log(*args): | ||
sys.stdout.write("\n".join(args)) | ||
|
||
|
||
def hit_pages(paths, times=3): | ||
_base_url = "http://localhost:8000" | ||
|
||
for path in paths: | ||
for _ in range(times): | ||
time.sleep(0.5) | ||
url = f"{_base_url}{path}" | ||
requests.get(url) | ||
|
||
_log("All done") | ||
|
||
|
||
if __name__ == "__main__": | ||
hit_pages(paths) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.