Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-144319:madvise(MADV_HUGEPAGE)#144353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
maurycy wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
frommaurycy:pymalloc-madv-hugepage

Conversation

@maurycy
Copy link
Contributor

@maurycymaurycy commentedJan 31, 2026
edited
Loading

The hint enables Transparent Huge Pages on systems withmadvise, which seems to be the default on Ubuntu and Fedora,at least according to this article.

More on THP:

Importantly, it seems to cary noSIGBUS risk. mimalloc seems to already do this withMIMALLOC_LARGE_OS_PAGES=1.

Reusing the benchmark from#144319:

bench_obmalloc.py
importsys,gcdefbench_small_object_churn():objs= []for_inrange(200_000):objs.append(bytearray(64))for_inrange(200_000):objs.append(bytearray(64));objs.pop(0)defbench_bulk_small_alloc():objs= [bytearray(48)for_inrange(1_000_000)]foroinobjs:o[0]=1defbench_dict_churn():for_inrange(500_000):d= {"a":1,"b":2,"c":3,"d":4};delddefbench_mixed_sizes():sizes= [8,16,24,32,48,64,96,128,192,256,384,512]objs= [bytearray(sizes[i%12])foriinrange(500_000)]defbench_fragmentation():objs= [bytearray(128)for_inrange(500_000)]foriinrange(0,len(objs),2):objs[i]=Noneforiinrange(0,len(objs),2):objs[i]=bytearray(128)defbench_list_of_tuples():objs= [(i,i+1,i+2)foriinrange(1_000_000)]defbench_class_instances():classPt:__slots__= ('x','y','z')def__init__(s,x,y,z):s.x=x;s.y=y;s.z=zobjs= [Pt(i,i+1,i+2)foriinrange(500_000)]defbench_arena_pressure():layers= [[bytearray(256)for_inrange(200_000)]for_inrange(10)]defbench_random_walk():importrandom;random.seed(42)objs= [bytearray(64)for_inrange(1_000_000)]idx=list(range(len(objs)));random.shuffle(idx)foriinidx:objs[i][0]=i&0xffBENCHMARKS=dict(small_object_churn=bench_small_object_churn,bulk_small_alloc=bench_bulk_small_alloc,dict_churn=bench_dict_churn,mixed_sizes=bench_mixed_sizes,fragmentation=bench_fragmentation,list_of_tuples=bench_list_of_tuples,class_instances=bench_class_instances,arena_pressure=bench_arena_pressure,random_walk=bench_random_walk)if__name__=="__main__":gc.collect();gc.disable();BENCHMARKS[sys.argv[1]]();gc.enable()

on

[126] 2026-01-31T02:32:04.127734128+0100 maurycy@eiger /home/maurycy  % sudo cat /sys/kernel/mm/transparent_hugepage/enabledalways [madvise] never

Where the baseline is themain branch

Wall-clock time

BenchmarkBaselineWith MADV_HUGEPAGEChange
fragmentation0.107s0.101s-5.4%
bulk_small_alloc0.126s0.121s-4.1%
class_instances0.078s0.076s-2.9%
list_of_tuples0.102s0.101s-1.2%
mixed_sizes0.085s0.084s-1.1%
random_walk0.517s0.515s-0.4%
arena_pressure0.325s0.326s+0.3%

dTLB load misses

BenchmarkBaselineWith MADV_HUGEPAGEChange
fragmentation123,39099,413-19.4%
arena_pressure280,228237,222-15.3%
bulk_small_alloc93,89485,661-8.8%
list_of_tuples88,01981,778-7.1%

It's smaller thanMAP_HUGETLB becauseMADV_HUGEPAGE is just a hint, so maybe khugepaged did not kick in yet.

I noted no regression withTHP=always.

The only thing that I'm wondering whether and how it should be guarded. Enabling by default seems risky, but it's not exactly--with-pymalloc-hugepages. That's why I'm opening this as a draft.

Meanwhile, I'm running the wholepyperformance suite to check if there are any regressions, I will update this PR description once known.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@maurycy

[8]ページ先頭

©2009-2026 Movatter.jp