Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 64KB page sizes in the GC #5373

Closed
wants to merge 1 commit into from
Closed

Conversation

peterzhu2118
Copy link
Member

Many systems (e.g. PowerPC) have 64KB system page sizes, which means we cannot use mmap if we used 16KB pages sizes in the GC. This commit changes the GC page size to be 64KB.

Many systems (e.g. PowerPC) have 64KB system page sizes, which means we
cannot use mmap if we used 16KB pages sizes in the GC. This commit
changes the GC page size to be 64KB.
@shyouhei shyouhei requested a review from ko1 December 31, 2021 14:50
@ko1
Copy link
Contributor

ko1 commented Jan 4, 2022

We choose heap-page-size 16KB to increase the chance to free heap-pages.
(we can free a heap-page if all slots in the page are empty)
In theory, with 64KB, it is harder to see all empty slots.

HOWEVER, I don't have good evidence which size is better.

Could you consider to measure with the sizes? It is not easy task though.
I think we can try with 8, 16, 32, 64, 128, 256, 512, 1024KB heap-page-size and run some applications.
We may observe some interesting metrics like:

  • GC stat
    • total_freed_pages
    • total_allocated_pages
    • heap_allocated_pages at last
  • Linux process stat
    • RSS (last)
    • RSS (HWM)
  • Execution time

@peterzhu2118
Copy link
Member Author

I benchmarked this on discourse benchmark. I benchmarked master (16KB), this branch (64KB), and this branch modified for 128KB page size.

I have posted the results below. It looks like compared to 16KB page size, 64KB page size uses more memory (about 10% more), but 128KB page size has about the same memory usage. This has to do with how the GC grows the heaps, so I expect that on some applications it will use more memory but may use less on others.

In terms of response times, it looks like 16KB and 128KB are very similar. It looks like 64KB is faster than 16KB, but this is probably because it uses more memory.

I think the impact of moving to 64KB pages is minimal and we get extra benefits from it (e.g. supporting compaction on 64KB page size systems).

16KB

categories:
  50: 54
  75: 55
  90: 60
  99: 121
home:
  50: 94
  75: 97
  90: 102
  99: 234
topic:
  50: 37
  75: 37
  90: 38
  99: 77
categories_admin:
  50: 55
  75: 55
  90: 61
  99: 136
home_admin:
  50: 93
  75: 96
  90: 102
  99: 251
topic_admin:
  50: 36
  75: 37
  90: 37
  99: 80
timings:
  load_rails: 1838
ruby-version: 3.2.0-p-1
rss_kb: 354732
pss_kb: 343888
architecture: amd64
physicalprocessorcount: 2
memorysize: 188.53 GiB
kernelversion: 5.11.0
virtual: kvm
operatingsystem: Ubuntu
processor0: Intel(R) Xeon(R) Platinum 8275CL CPU @ 3.00GHz

64KB

categories:
  50: 54
  75: 56
  90: 60
  99: 153
home:
  50: 92
  75: 95
  90: 100
  99: 182
topic:
  50: 37
  75: 37
  90: 39
  99: 59
categories_admin:
  50: 54
  75: 55
  90: 59
  99: 99
home_admin:
  50: 93
  75: 95
  90: 102
  99: 171
topic_admin:
  50: 37
  75: 37
  90: 38
  99: 56
timings:
  load_rails: 1865
ruby-version: 3.2.0-p-1
rss_kb: 396364
pss_kb: 385573
architecture: amd64
physicalprocessorcount: 2
memorysize: 188.53 GiB
kernelversion: 5.11.0
virtual: kvm
operatingsystem: Ubuntu
processor0: Intel(R) Xeon(R) Platinum 8275CL CPU @ 3.00GHz

128KB

categories:
  50: 53
  75: 55
  90: 59
  99: 105
home:
  50: 92
  75: 97
  90: 101
  99: 175
topic:
  50: 36
  75: 37
  90: 39
  99: 57
categories_admin:
  50: 54
  75: 55
  90: 60
  99: 102
home_admin:
  50: 93
  75: 98
  90: 102
  99: 174
topic_admin:
  50: 37
  75: 37
  90: 39
  99: 55
timings:
  load_rails: 1875
ruby-version: 3.2.0-p-1
rss_kb: 353548
pss_kb: 342694
architecture: amd64
physicalprocessorcount: 2
memorysize: 188.53 GiB
kernelversion: 5.11.0
virtual: kvm
operatingsystem: Ubuntu
processor0: Intel(R) Xeon(R) Platinum 8275CL CPU @ 3.00GHz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants