Bug 209360

Summary: Can bmalloc work on systems with 64 kB pages?
Product: WebKit Reporter: Michael Catanzaro <mcatanzaro>
Component: bmallocAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: basuke, fpizlo, ggaren, jz_xue, mcatanzaro, msaboff, saam, ysuzuki
Priority: P2    
Version: WebKit Nightly Build   
Hardware: PC   
OS: Linux   
See Also: https://bugs.webkit.org/show_bug.cgi?id=209236
https://bugs.webkit.org/show_bug.cgi?id=217989
Bug Depends on:    
Bug Blocks: 209670    

Michael Catanzaro
Reported 2020-03-20 13:35:56 PDT
Currently, WebKitFeatures.cmake enables bmalloc on aarch64, x86_64, arm, and mips. All other architectures build with USE_SYSTEM_MALLOC=ON. It seems one of the reasons that bmalloc does not work on many CPU architectures is that it doesn't support systems with 64 kB page size. We can be confident of this because bmalloc on aarch64 works in Fedora (which uses 4 kB pages) but not in RHEL (64 kB pages). Looking through bmalloc for potentially-problematic places, I found configSizeToProtect in Gigacage.h set to 16 kB, which is too small. I also found in Sizes.h: static constexpr size_t smallLineSize = 256; static constexpr size_t smallPageSize = 4 * kB; static constexpr size_t smallPageLineCount = smallPageSize / smallLineSize; static constexpr size_t maskSizeClassMax = 512; static constexpr size_t smallMax = 32 * kB; static constexpr size_t pageSizeMax = smallMax * 2; static constexpr size_t pageClassCount = pageSizeMax / smallPageSize; I guess we would need to raise smallPageSize and smallMax both to 64 kB? Before I try this, are there any other theoretical problems that would stop bmalloc from working on a given CPU architecture? Are there page size assumptions anywhere else? Does it make endianness assumptions?
Attachments
Yusuke Suzuki
Comment 1 2020-03-31 17:16:01 PDT
If you change these values, please do not change them in the existing architectures. We are tuning performance / memory-consumption heavily on the current numbers.
Saam Barati
Comment 2 2020-03-31 17:56:46 PDT
I don't think that's right, since malloc is already tuned to 16kb pages. It's not obvious setting "smallPageSize" to 64kb actually makes bmalloc better
Yusuke Suzuki
Comment 3 2020-03-31 20:26:18 PDT
(In reply to Saam Barati from comment #2) > I don't think that's right, since malloc is already tuned to 16kb pages. > It's not obvious setting "smallPageSize" to 64kb actually makes bmalloc > better physical page size and smallPageSize are different concept, no? https://bugs.webkit.org/attachment.cgi?id=274931&action=review " smallPageSize is now unrelated to the OS's page size -- it just reflects the optimal unit of memory to recycle between small objects."
Saam Barati
Comment 4 2020-03-31 21:20:27 PDT
Your question is a more general one: does bmalloc work with 64kb pages. Why wouldn’t it? I’d guess the only thing needing to be changed is “configSizeToProtect” in Gigacage In the previous bug where you reference this bug, you say this is a bmalloc issue. What exactly is the issue?
Michael Catanzaro
Comment 5 2020-04-01 07:31:22 PDT
Saam left some additional hints here: https://bugs.webkit.org/show_bug.cgi?id=209670#c22
Michael Catanzaro
Comment 6 2020-05-15 14:26:27 PDT
*** Bug 200566 has been marked as a duplicate of this bug. ***
Michael Catanzaro
Comment 7 2020-10-20 16:31:35 PDT
Carlos Lopez found there is also ConfigAlignment and another ConfigSizeToProtect in mbmalloc.cpp.
Note You need to log in before you can comment on or make changes to this bug.