Skip to content

Update page size to 64k #50600

New issue

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

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

gbaraldi
Copy link
Member

@gbaraldi gbaraldi commented Jul 19, 2023

16k is a small page size (64k seems to be more usual).
master

┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │      11679704632873759116418031655059 │
│  median │      11809713333193810118219851655960 │
│ maximum │      12023730134243877121431873658161 │
│   stdev │        10877453813590891 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
category = "binary_tree"
bench = "tree_immutable.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │       205165911254626239253532 │
│  median │       209068511756727243853733 │
│ maximum │       215271312159430257954633 │
│   stdev │         402031816330 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
bench = "tree_mutable.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │       370514122081204582195116638 │
│  median │       372914292111218602237117638 │
│ maximum │       392015432281315642312118339 │
│   stdev │         633863323960 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘

PR

┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │      1024757822960282098718359653556 │
│  median │      1082463663287306999530734655059 │
│ maximum │      10872641033263107100932808658159 │
│   stdev │        25125414311374657121 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
category = "binary_tree"
bench = "tree_immutable.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │       168734410723418240253220 │
│  median │       169434911023920244453521 │
│ maximum │       170335711824221251653821 │
│   stdev │          543214530 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
bench = "tree_mutable.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │       2898708206501352205118824 │
│  median │       2906713208505352237119225 │
│ maximum │       2910717210509352260119925 │
│   stdev │          431302130 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘

Should we change the size classes/include larger classes? Also this makes a bigger difference than what I had imagined.

@gbaraldi gbaraldi requested review from vchuravy and d-netto July 19, 2023 18:15
@oscardssmith
Copy link
Member

Are the max heap measurements measuring pages or bytes? It would be good to see if there is a substantial heap size impact.

@LilithHafner
Copy link
Member

Is it possible to run these benchmarks on an old machine?

@gbaraldi
Copy link
Member Author

This change shouldn't increase max heap by that much, you just lose a bit of granularity on the heap size (64k vs 16k). We have 48 size classes currently and that amounts to 3MB in total, which isn't that big anyway.

@oscardssmith
Copy link
Member

Theoretically that's true, but the 64k pages increases the potential risks of fragmentation.

@gbaraldi
Copy link
Member Author

gbaraldi commented Jul 19, 2023

Again, the extra fragmentation here is limited to 1 page per size class. Remembering that this is neither OS pages nor the mmaped pages, this is an internal GC thing. We ask memory in 64MB blocks from the OS and split it between these GC pages.

@JeffBezanson
Copy link
Member

Again, the extra fragmentation here is limited to 1 page per size class.

I don't see how that's true? Isn't it always possible to have a worst case of many objects with only one live object per page, in which case bigger pages means more fragmentation? I still think this change is probably worth doing, just trying to understand this statement.

@JeffBezanson JeffBezanson added the GC Garbage collector label Jul 19, 2023
@gbaraldi
Copy link
Member Author

I guess the way I phrased it wasn't the best. In a pathological case where you manage to leave one object alive per page this makes it potentially 4x worse. It does also make it harder for objects to span that many more pages because the pages are now bigger, and fortunately block sized heaps like ours tend to limit how much fragmentation you get simply because you don't get into a situation where the objects don't fit in the heap anymore.

@oscardssmith oscardssmith added the performance Must go faster label Jul 19, 2023
@vchuravy
Copy link
Member

The impact is surprisingly large. It looks like the mange change is in sweep? Could you profile to determine whether the change is that we do 4x less madvise?

@d-netto
Copy link
Member

d-netto commented Jul 20, 2023

It would also be interesting to see how it behaves with concurrent page sweeping enabled.

@gbaraldi
Copy link
Member Author

I haven't done extensive profiling, it's just that the initial results were promising enough to open a PR.

@oscardssmith
Copy link
Member

bump. should we merge this?

@d-netto
Copy link
Member

d-netto commented Sep 22, 2023

Just want to note that, with a 16k page size, we're already seeing substantial amounts of memory lost to fragmentation in some of our workloads. This PR has the possibility of making things worse on that end.

@d-netto
Copy link
Member

d-netto commented Mar 21, 2025

Seems like this PR got stale, and from a fragmentation perspective, increasing page size will make things worse.

Fine to close it?

@oscardssmith
Copy link
Member

I think this PR is likely worth updating. Fragmentation is an issue for some, but not all workloads, and the bigger page size is a pretty nice performance improvement. For reference, mimalloc also uses 64k pages suggesting it is likely a good default.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
GC Garbage collector performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants