René's URL Explorer Experiment


Title: Incremental GC causes a significant slowdown for Sphinx · Issue #124567 · python/cpython · GitHub

Open Graph Title: Incremental GC causes a significant slowdown for Sphinx · Issue #124567 · python/cpython

X Title: Incremental GC causes a significant slowdown for Sphinx · Issue #124567 · python/cpython

Description: Bug report A significant performance regression in Sphinx caused by changes in CPython 3.13 Here is a script that does the following things: Replaces the contents of all CPython documentation files except Doc/library/typing.rst with simp...

Open Graph Description: Bug report A significant performance regression in Sphinx caused by changes in CPython 3.13 Here is a script that does the following things: Replaces the contents of all CPython documentation files...

X Description: Bug report A significant performance regression in Sphinx caused by changes in CPython 3.13 Here is a script that does the following things: Replaces the contents of all CPython documentation files...

Opengraph URL: https://github.com/python/cpython/issues/124567

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incremental GC causes a significant slowdown for Sphinx","articleBody":"# Bug report\r\n\r\n## A significant performance regression in Sphinx caused by changes in CPython 3.13\r\n\r\nHere is a script that does the following things:\r\n1. Replaces the contents of all CPython documentation files except `Doc/library/typing.rst` with simply `\"foo\"`\r\n2. Creates a virtual environment\r\n3. Installs our doc dependencies into the environment (making sure that we use pure-Python versions for all doc dependencies rather than built wheels that might include C extensions)\r\n4. Times how long it takes to build the docs using that environment\r\n5. Restores all the modified docs files and deletes the virtual environment again\r\n\r\n\u003cdetails\u003e\r\n\u003csummary\u003eThe script\u003c/summary\u003e\r\n\r\n```py\r\nimport contextlib\r\nimport shutil\r\nimport subprocess\r\nimport time\r\nimport venv\r\nfrom pathlib import Path\r\n\r\ndef run(args):\r\n    try:\r\n        subprocess.run(args, check=True, capture_output=True, text=True)\r\n    except subprocess.CalledProcessError as e:\r\n        print(e.stdout)\r\n        print(e.stderr)\r\n        raise\r\n\r\n\r\nwith contextlib.chdir(\"Doc\"):\r\n    try:\r\n        for path in Path(\".\").iterdir():\r\n            if path.is_dir() and not str(path).startswith(\".\"):\r\n                for doc_path in path.rglob(\"*.rst\"):\r\n                    if doc_path != Path(\"library/typing.rst\"):\r\n                        doc_path.write_text(\"foo\")\r\n\r\n        venv.create(\".venv\", with_pip=True)\r\n\r\n        run([\r\n            \".venv/bin/python\",\r\n            \"-m\",\r\n            \"pip\",\r\n            \"install\",\r\n            \"-r\",\r\n            \"requirements.txt\",\r\n            \"--no-binary=':all:'\",\r\n        ])\r\n\r\n        start = time.perf_counter()\r\n\r\n        run([\r\n            \".venv/bin/python\",\r\n            \"-m\",\r\n            \"sphinx\",\r\n            \"-b\",\r\n            \"html\",\r\n            \".\",\r\n            \"build/html\",\r\n            \"library/typing.rst\",\r\n        ])\r\n\r\n        print(time.perf_counter() - start)\r\n        shutil.rmtree(\".venv\")\r\n        shutil.rmtree(\"build\")\r\n    finally:\r\n        subprocess.run([\"git\", \"restore\", \".\"], check=True, capture_output=True)\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\nUsing a PGO-optimized build with LTO enabled, the script reports that there is a significant performance regression in Sphinx's parsing and building of `library/typing.rst` between `v3.13.0a1` and https://github.com/python/cpython/commit/909c6f718913e713c990d69e6d8a74c05f81e2c2:\r\n- On `v13.0a1` the script reports a Sphinx build time of between 1.27s and 1.29s (I ran the script several times)\r\n- On https://github.com/python/cpython/commit/ede1504c4b37b98636bf935679746ba2932f5677, a Sphinx build time of between 1.76 and 1.82s is reported by the script (a roughly 48% regression).\r\n\r\nA similar regression is reported in this (much slower) variation of the script that builds the entire set of CPython's documentation rather than just `library/typing.rst`.\r\n\r\n\u003cdetails\u003e\r\n\u003csummary\u003eMore comprehensive variation of the script\u003c/summary\u003e\r\n\r\n```py\r\nimport contextlib\r\nimport shutil\r\nimport subprocess\r\nimport time\r\nimport venv\r\n\r\ndef run(args):\r\n    subprocess.run(args, check=True, text=True)\r\n\r\n\r\nwith contextlib.chdir(\"Doc\"):\r\n    venv.create(\".venv\", with_pip=True)\r\n\r\n    run([\r\n        \".venv/bin/python\",\r\n        \"-m\",\r\n        \"pip\",\r\n        \"install\",\r\n        \"-r\",\r\n        \"requirements.txt\",\r\n        \"--no-binary=':all:'\",\r\n    ])\r\n\r\n    start = time.perf_counter()\r\n\r\n    run([\r\n        \".venv/bin/python\",\r\n        \"-m\",\r\n        \"sphinx\",\r\n        \"-b\",\r\n        \"html\",\r\n        \".\",\r\n        \"build/html\",\r\n    ])\r\n\r\n    print(time.perf_counter() - start)\r\n    shutil.rmtree(\".venv\")\r\n    shutil.rmtree(\"build\")\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\nThe PGO-optimized timings for building the entire CPython documentation is as follows:\r\n- `v3.13.0a1`: 45.5s\r\n- https://github.com/python/cpython/commit/ede1504c4b37b98636bf935679746ba2932f5677: 62.7s\r\n\r\nThis indicates a 38% performance regression for building the entire set of CPython's documentation.\r\n\r\n## Cause of the performance regression\r\n\r\nThis performance regression was initially discovered in #118891: in our own CI, we use a fresh build of CPython in our Doctest CI workflow (since otherwise, we wouldn't be testing the tip of the `main` branch), and it was observed that the CI job was taking significantly longer on the `3.13` branch than the `3.12` branch. In the context of our CI, the performance regression is even worse, because of the fact that our Doctest CI workflow uses a debug build rather than a PGO-optimized build, and the regression is even more pronounced in a Debug build.\r\n\r\nUsing a debug build, I used the first script posted above to bisect the performance regression to commit 15309329b65a285cb7b3071f0f08ac964b61411b (below), which seemed to cause a performance regression of around 300% in a debug build\r\n\r\n```\r\n15309329b65a285cb7b3071f0f08ac964b61411b is the first bad commit\r\ncommit 15309329b65a285cb7b3071f0f08ac964b61411b\r\nAuthor: Mark Shannon \u003cmark@hotpy.org\u003e\r\nDate:   Wed Mar 20 08:54:42 2024 +0000\r\n\r\n    GH-108362: Incremental Cycle GC (GH-116206)\r\n\r\n Doc/whatsnew/3.13.rst                              |  30 +\r\n Include/internal/pycore_gc.h                       |  41 +-\r\n Include/internal/pycore_object.h                   |  18 +-\r\n Include/internal/pycore_runtime_init.h             |   8 +-\r\n Lib/test/test_gc.py                                |  72 +-\r\n .../2024-01-07-04-22-51.gh-issue-108362.oB9Gcf.rst |  12 +\r\n Modules/gcmodule.c                                 |  25 +-\r\n Objects/object.c                                   |  21 +\r\n Objects/structseq.c                                |   5 +-\r\n Python/gc.c                                        | 806 +++++++++++++--------\r\n Python/gc_free_threading.c                         |  23 +-\r\n Python/import.c                                    |   2 +-\r\n Python/optimizer.c                                 |   2 +-\r\n Tools/gdb/libpython.py                             |   7 +-\r\n 14 files changed, 684 insertions(+), 388 deletions(-)\r\n create mode 100644 Misc/NEWS.d/next/Core and Builtins/2024-01-07-04-22-51.gh-issue-108362.oB9Gcf.rst\r\n```\r\n\r\nPerformance was then significantly improved by commit e28477f214276db941e715eebc8cdfb96c1207d9 (below), but it's unfortunately still the case that Sphinx is far slower on Python 3.13 than on Python 3.12:\r\n\r\n```\r\ncommit e28477f214276db941e715eebc8cdfb96c1207d9\r\nAuthor: Mark Shannon \u003cmark@hotpy.org\u003e\r\nDate:   Fri Mar 22 18:43:25 2024 +0000\r\n\r\n    GH-117108: Change the size of the GC increment to about 1% of the total heap size. (GH-117120)\r\n\r\n Include/internal/pycore_gc.h                       |  3 +-\r\n Lib/test/test_gc.py                                | 35 +++++++++++++++-------\r\n .../2024-03-21-12-10-11.gh-issue-117108._6jIrB.rst |  3 ++\r\n Modules/gcmodule.c                                 |  2 +-\r\n Python/gc.c                                        | 30 +++++++++----------\r\n Python/gc_free_threading.c                         |  2 +-\r\n 6 files changed, 47 insertions(+), 28 deletions(-)\r\n create mode 100644 Misc/NEWS.d/next/Core and Builtins/2024-03-21-12-10-11.gh-issue-117108._6jIrB.rst\r\n```\r\n\r\nSee https://github.com/python/cpython/issues/118891#issuecomment-2375334948 for more details on the bisection results.\r\n\r\nProfiling by @nascheme in https://github.com/python/cpython/issues/118891#issuecomment-2375362608 and https://github.com/python/cpython/issues/118891#issuecomment-2375446761 also confirms that Sphinx spends a significant amount of time in the GC, so it seems very likely that the changes to introduce an incremental GC in Python 3.13 is the cause of this performance regression.\r\n\r\nCc. @markshannon for expertise on the new incremental GC, and cc. @hugovk / @AA-Turner for Sphinx expertise.\r\n\r\n### CPython versions tested on:\r\n\r\n3.12, 3.13, CPython main branch\r\n\r\n### Operating systems tested on:\r\n\r\nmacOS\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-124717\n* gh-124770\n* gh-126777\n* gh-127009\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/AlexWaygood","@type":"Person","name":"AlexWaygood"},"datePublished":"2024-09-26T00:02:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":25},"url":"https://github.com/124567/cpython/issues/124567"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:9fcad06a-c02f-92a2-8284-637d2562a591
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9506:8ADEB:8698E3:B7DFE0:6969E3F6
html-safe-noncee19762553c39684ad110877f6914c65b207de2ec4cdb97cb925ec9627609eaa7
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTA2OjhBREVCOjg2OThFMzpCN0RGRTA6Njk2OUUzRjYiLCJ2aXNpdG9yX2lkIjoiNjIyNzA2MjQ2NzYzMjY4NjA3MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac25c48b753130b7866491ad0cb9fe664ad6b5a26851b6189df09e3806ebd6b058
hovercard-subject-tagissue:2549191807
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/124567/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a4509dfde2e33efcd53b31c72ec365c9415968f2eb313ada21693f37c70a9f16/python/cpython/issues/124567
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a4509dfde2e33efcd53b31c72ec365c9415968f2eb313ada21693f37c70a9f16/python/cpython/issues/124567
og:image:altBug report A significant performance regression in Sphinx caused by changes in CPython 3.13 Here is a script that does the following things: Replaces the contents of all CPython documentation files...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameAlexWaygood
hostnamegithub.com
expected-hostnamegithub.com
None7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasebdde15ad1b403e23b08bbd89b53fbe6bdf688cad
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/124567#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F124567
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F124567
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/124567
Reloadhttps://github.com/python/cpython/issues/124567
Reloadhttps://github.com/python/cpython/issues/124567
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/124567
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/issues/124567
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/124567
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/124567
Incremental GC causes a significant slowdown for Sphinxhttps://github.com/python/cpython/issues/124567#top
https://github.com/markshannon
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
performancePerformance or resource usagehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22performance%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/AlexWaygood
https://github.com/AlexWaygood
AlexWaygoodhttps://github.com/AlexWaygood
on Sep 26, 2024https://github.com/python/cpython/issues/124567#issue-2549191807
909c6f7https://github.com/python/cpython/commit/909c6f718913e713c990d69e6d8a74c05f81e2c2
ede1504https://github.com/python/cpython/commit/ede1504c4b37b98636bf935679746ba2932f5677
ede1504https://github.com/python/cpython/commit/ede1504c4b37b98636bf935679746ba2932f5677
#118891https://github.com/python/cpython/issues/118891
1530932https://github.com/python/cpython/commit/15309329b65a285cb7b3071f0f08ac964b61411b
e28477fhttps://github.com/python/cpython/commit/e28477f214276db941e715eebc8cdfb96c1207d9
#118891 (comment)https://github.com/python/cpython/issues/118891#issuecomment-2375334948
@naschemehttps://github.com/nascheme
#118891 (comment)https://github.com/python/cpython/issues/118891#issuecomment-2375362608
#118891 (comment)https://github.com/python/cpython/issues/118891#issuecomment-2375446761
@markshannonhttps://github.com/markshannon
@hugovkhttps://github.com/hugovk
@AA-Turnerhttps://github.com/AA-Turner
GH-124567: Reduce overhead of cycle GC. #124717https://github.com/python/cpython/pull/124717
[3.13] GH-124567: Revert the Incremental GC in 3.13 #124770https://github.com/python/cpython/pull/124770
GH-124567: Reduce overhead of debug build for GC. Should help CI performance #126777https://github.com/python/cpython/pull/126777
GH-124567: Replace quadratic assert with linear one #127009https://github.com/python/cpython/pull/127009
markshannonhttps://github.com/markshannon
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
performancePerformance or resource usagehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22performance%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
Release and Deferred blockers 🚫https://github.com/orgs/python/projects/2
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.