René's URL Explorer Experiment


Title: Issue · GitHub

Open Graph Title: Issue · python/cpython

X Title: Issue · python/cpython

Description: The Python programming language. Contribute to python/cpython development by creating an account on GitHub.

Open Graph Description: The Python programming language. Contribute to python/cpython development by creating an account on GitHub.

X Description: The Python programming language. Contribute to python/cpython development by creating an account on GitHub.

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add huge pages support for pymalloc","articleBody":"pymalloc allocates small objects from contiguous regions called arenas. On 64-bit platforms each arena is 1 MiB, obtained via `mmap(MAP_PRIVATE|MAP_ANONYMOUS)` and backed by 256 standard 4 KiB pages. Each page needs its own TLB entry, and the x86_64 dTLB only holds 64-128 entries for 4K pages, so a single arena already overflows TLB capacity, and any non-trivial Python program touches many arenas.\n\nMost modern operating systems support \"huge pages\": memory pages much larger than the default 4 KiB. On x86_64 Linux the standard huge page size is 2 MiB. A single 2 MiB huge page is covered by one TLB entry instead of 512 entries for the equivalent range of 4 KiB pages. This dramatically reduces TLB pressure for workloads that touch large contiguous allocations. On Linux, explicit huge pages are allocated via `mmap` with the `MAP_HUGETLB` flag (available since kernel 2.6.32) from a pre-reserved pool configured through `/proc/sys/vm/nr_hugepages`. On Windows, the equivalent is `VirtualAlloc` with `MEM_LARGE_PAGES`.\n\nI'd like to propose adding a `./configure --with-pymalloc-hugepages` option that increases `ARENA_BITS` from 20 to 21 (1 MiB -\u003e 2 MiB) and makes `_PyMem_ArenaAlloc()` try `mmap(MAP_HUGETLB)` first, falling back to regular `mmap` if the huge page pool is exhausted. On Windows the equivalent would be `VirtualAlloc(MEM_LARGE_PAGES)` with fallback. `_PyMem_ArenaFree()` needs no changes since `munmap` handles huge pages identically. All derived constants (`ARENA_SIZE`, `MAX_POOLS_IN_ARENA`, radix tree bit widths, `nfp2lasta` sizing) adjust automatically from `ARENA_BITS`. \n\nThe flag is opt-in and off by default. `MAP_HUGETLB` requires the kernel to have huge pages pre-allocated; without them the fallback path produces identical behavior to a non-hugepages build. On Linux, huge pages are managed through `/proc/sys/vm/nr_hugepages`. To allocate 128 huge pages (256 MiB on x86_64 where the default huge page size is 2 MiB):\n\n```bash\n# Allocate (requires root)\necho 128 | sudo tee /proc/sys/vm/nr_hugepages\n\n# Verify\ngrep HugePages /proc/meminfo\n# HugePages_Total:     128\n# HugePages_Free:      128\n\n# Make persistent across reboots by adding to /etc/sysctl.conf:\n# vm.nr_hugepages = 128\n```\n\nEach arena consumes one huge page. If the pool runs out, obmalloc falls back to regular 4K pages transparently.\n\nI benchmarked on an i9-14900KS, Linux 6.18.3, GCC 15.2.1 on main with `nr_hugepages=128`. Measured with `perf stat -r 100` using `cpu_core` counters. GC disabled during benchmarks.\n\nWall-clock results:\n\n| Benchmark | Default | Hugepages | Change |\n|---|---|---|---|\n| list_of_tuples (1M 3-tuples) | 0.172s | 0.121s | **-29.5%** |\n| fragmentation (500K alloc/free/realloc) | 0.162s | 0.119s | **-26.5%** |\n| mixed_sizes (500K, 12 size classes) | 0.141s | 0.106s | **-25.1%** |\n| bulk_small_alloc (1M bytearrays) | 0.205s | 0.160s | **-22.1%** |\n| class_instances (500K \\_\\_slots\\_\\_) | 0.120s | 0.096s | **-20.0%** |\n| arena_pressure (10x200K objects) | 0.509s | 0.448s | **-12.1%** |\n| random_walk (1M, shuffled access) | 0.822s | 0.759s | **-7.6%** |\n\ndTLB miss reductions:\n\n| Benchmark | dTLB Load Miss | dTLB Store Miss | Page Faults |\n|---|---|---|---|\n| fragmentation | -95.9% | -94.7% | -94.5% |\n| random_walk | -93.1% | -98.9% | -91.6% |\n| bulk_small_alloc | -91.4% | -94.5% | -93.5% |\n| list_of_tuples | -88.0% | -93.7% | -94.1% |\n| class_instances | -84.3% | -91.8% | -92.1% |\n| mixed_sizes | -80.8% | -76.5% | -78.2% |\n\nThe perf command used per benchmark:\n\n```bash\nEVENTS=\"dTLB-loads,dTLB-load-misses,dTLB-stores,dTLB-store-misses,iTLB-load-misses,cache-misses,cache-references,instructions,cycles,page-faults\"\nperf stat -r 10 -e \"$EVENTS\" ./python bench_obmalloc.py fragmentation\n```\n\n\u003cdetails\u003e\n\u003csummary\u003ebench_obmalloc.py\u003c/summary\u003e\n\n```python\nimport sys, gc\n\ndef bench_small_object_churn():\n    objs = []\n    for _ in range(200_000): objs.append(bytearray(64))\n    for _ in range(200_000): objs.append(bytearray(64)); objs.pop(0)\n\ndef bench_bulk_small_alloc():\n    objs = [bytearray(48) for _ in range(1_000_000)]\n    for o in objs: o[0] = 1\n\ndef bench_dict_churn():\n    for _ in range(500_000): d = {\"a\": 1, \"b\": 2, \"c\": 3, \"d\": 4}; del d\n\ndef bench_mixed_sizes():\n    sizes = [8, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512]\n    objs = [bytearray(sizes[i % 12]) for i in range(500_000)]\n\ndef bench_fragmentation():\n    objs = [bytearray(128) for _ in range(500_000)]\n    for i in range(0, len(objs), 2): objs[i] = None\n    for i in range(0, len(objs), 2): objs[i] = bytearray(128)\n\ndef bench_list_of_tuples():\n    objs = [(i, i+1, i+2) for i in range(1_000_000)]\n\ndef bench_class_instances():\n    class Pt:\n        __slots__ = ('x', 'y', 'z')\n        def __init__(s, x, y, z): s.x = x; s.y = y; s.z = z\n    objs = [Pt(i, i+1, i+2) for i in range(500_000)]\n\ndef bench_arena_pressure():\n    layers = [[bytearray(256) for _ in range(200_000)] for _ in range(10)]\n\ndef bench_random_walk():\n    import random; random.seed(42)\n    objs = [bytearray(64) for _ in range(1_000_000)]\n    idx = list(range(len(objs))); random.shuffle(idx)\n    for i in idx: objs[i][0] = i \u0026 0xff\n\nBENCHMARKS = dict(small_object_churn=bench_small_object_churn,\n    bulk_small_alloc=bench_bulk_small_alloc, dict_churn=bench_dict_churn,\n    mixed_sizes=bench_mixed_sizes, fragmentation=bench_fragmentation,\n    list_of_tuples=bench_list_of_tuples, class_instances=bench_class_instances,\n    arena_pressure=bench_arena_pressure, random_walk=bench_random_walk)\n\nif __name__ == \"__main__\":\n    gc.collect(); gc.disable(); BENCHMARKS[sys.argv[1]](); gc.enable()\n```\n\n\u003c/details\u003e\n\nFull reproduction:\n\n```bash\n./configure \u0026\u0026 make -j$(nproc) \u0026\u0026 cp python python_default\n./configure --with-pymalloc-hugepages \u0026\u0026 make -j$(nproc) \u0026\u0026 cp python python_hugepages\necho 128 | sudo tee /proc/sys/vm/nr_hugepages\n\nEVENTS=\"dTLB-loads,dTLB-load-misses,dTLB-stores,dTLB-store-misses,iTLB-load-misses,cache-misses,cache-references,instructions,cycles,page-faults\"\nfor b in bulk_small_alloc mixed_sizes fragmentation list_of_tuples class_instances arena_pressure random_walk; do\n    echo \"=== $b ===\"\n    perf stat -r 10 -e \"$EVENTS\" ./python_default bench_obmalloc.py \"$b\"\n    perf stat -r 10 -e \"$EVENTS\" ./python_hugepages bench_obmalloc.py \"$b\"\ndone\n```\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-144320\n* gh-144331\n* gh-144353\n* gh-144928\n* gh-147963\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/pablogsal","@type":"Person","name":"pablogsal"},"datePublished":"2026-01-29T01:40:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/144319/cpython/issues/144319"}

route-pattern/:user_id/:repository/issues/:id(.:format)
route-controllerissues
route-actionshow
fetch-noncev2:c22f74d3-a109-5d45-f9c5-2ba52f0e5be7
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDBF8:3061A4:6D66D8:95B2BD:6A51501C
html-safe-nonced36b86fdd6c65b5796fe0d6afecf6a2f2b4d5e818b846af9b1d91f865ad2567a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQkY4OjMwNjFBNDo2RDY2RDg6OTVCMkJEOjZBNTE1MDFDIiwidmlzaXRvcl9pZCI6IjY1ODU3NDMwMjQ4NTIxMjc3NzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac0e8df131cd0ff2cf4e38aeb69597ee0126e56b18606fcaabc4fa7a7145bfa555
hovercard-subject-tagrepository:81598961
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///issues/show
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/issues/144319
twitter:imagehttps://opengraph.githubassets.com/cd107b35a017fb0db1cda56aafbd7fbcf9eb95181788ee9bcb73d23f84d5e94c/python/cpython
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/cd107b35a017fb0db1cda56aafbd7fbcf9eb95181788ee9bcb73d23f84d5e94c/python/cpython
og:image:altThe Python programming language. Contribute to python/cpython development by creating an account on GitHub.
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None6f17634ed2af1d116850bcea6c63a70a4d72970f33ade1dd3eef3764b7e16994
turbo-cache-controlno-cache
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
release511bff6ea06e144ed085ff736aea4c6404987b00
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/144319#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F144319
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
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
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
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/enterprise/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%2F144319
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%2Fissues%2Fshow&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/144319
Reloadhttps://github.com/python/cpython/issues/144319
Reloadhttps://github.com/python/cpython/issues/144319
Please reload this pagehttps://github.com/python/cpython/issues/144319
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/144319
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 35k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.7k 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.3k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
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 and quality https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Add huge pages support for pymallochttps://github.com/python/cpython/issues/144319#top
https://github.com/nascheme
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com/pablogsal
pablogsalhttps://github.com/pablogsal
on Jan 29, 2026https://github.com/python/cpython/issues/144319#issue-3868235212
gh-144319: Add huge pages support for pymalloc #144320https://github.com/python/cpython/pull/144320
gh-144319: Fix huge page safety in pymalloc arenas #144331https://github.com/python/cpython/pull/144331
gh-144319: madvise(MADV_HUGEPAGE) #144353https://github.com/python/cpython/pull/144353
gh-144319: obtain SeLockMemoryPrivilege on Windows #144928https://github.com/python/cpython/pull/144928
gh-144319: Fix huge page leak in datastack chunk allocator #147963https://github.com/python/cpython/pull/147963
naschemehttps://github.com/nascheme
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
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.